test_ap_wps.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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. dev[0].request("SET ignore_old_scan_res 1")
  23. dev[0].dump_monitor()
  24. dev[0].request("WPS_PBC")
  25. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  26. if ev is None:
  27. raise Exception("Association with the AP timed out")
  28. status = dev[0].get_status()
  29. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  30. raise Exception("Not fully connected")
  31. if status['ssid'] != ssid:
  32. raise Exception("Unexpected SSID")
  33. if status['pairwise_cipher'] != 'CCMP':
  34. raise Exception("Unexpected encryption configuration")
  35. if status['key_mgmt'] != 'WPA2-PSK':
  36. raise Exception("Unexpected key_mgmt")
  37. def test_ap_wps_conf(dev, apdev):
  38. """WPS PBC provisioning with configured AP"""
  39. ssid = "test-wps-conf"
  40. hostapd.add_ap(apdev[0]['ifname'],
  41. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  42. "wpa_passphrase": "12345678", "wpa": "2",
  43. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
  44. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  45. logger.info("WPS provisioning step")
  46. hapd.request("WPS_PBC")
  47. dev[0].dump_monitor()
  48. dev[0].request("WPS_PBC")
  49. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  50. if ev is None:
  51. raise Exception("Association with the AP timed out")
  52. status = dev[0].get_status()
  53. if status['wpa_state'] != 'COMPLETED':
  54. raise Exception("Not fully connected")
  55. if status['bssid'] != apdev[0]['bssid']:
  56. raise Exception("Unexpected BSSID")
  57. if status['ssid'] != ssid:
  58. raise Exception("Unexpected SSID")
  59. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  60. raise Exception("Unexpected encryption configuration")
  61. if status['key_mgmt'] != 'WPA2-PSK':
  62. raise Exception("Unexpected key_mgmt")
  63. def test_ap_wps_twice(dev, apdev):
  64. """WPS provisioning with twice to change passphrase"""
  65. ssid = "test-wps-twice"
  66. params = { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  67. "wpa_passphrase": "12345678", "wpa": "2",
  68. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }
  69. hostapd.add_ap(apdev[0]['ifname'], params)
  70. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  71. logger.info("WPS provisioning step")
  72. hapd.request("WPS_PBC")
  73. dev[0].request("SET ignore_old_scan_res 1")
  74. dev[0].dump_monitor()
  75. dev[0].request("WPS_PBC")
  76. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  77. if ev is None:
  78. raise Exception("Association with the AP timed out")
  79. dev[0].request("DISCONNECT")
  80. logger.info("Restart AP with different passphrase and re-run WPS")
  81. hapd_global = hostapd.HostapdGlobal()
  82. hapd_global.remove(apdev[0]['ifname'])
  83. params['wpa_passphrase'] = 'another passphrase'
  84. hostapd.add_ap(apdev[0]['ifname'], params)
  85. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  86. logger.info("WPS provisioning step")
  87. hapd.request("WPS_PBC")
  88. dev[0].dump_monitor()
  89. dev[0].request("WPS_PBC")
  90. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  91. if ev is None:
  92. raise Exception("Association with the AP timed out")
  93. networks = dev[0].list_networks()
  94. if len(networks) > 1:
  95. raise Exception("Unexpected duplicated network block present")
  96. def test_ap_wps_conf_pin(dev, apdev):
  97. """WPS PIN provisioning with configured AP"""
  98. ssid = "test-wps-conf-pin"
  99. hostapd.add_ap(apdev[0]['ifname'],
  100. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  101. "wpa_passphrase": "12345678", "wpa": "2",
  102. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
  103. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  104. logger.info("WPS provisioning step")
  105. pin = dev[0].wps_read_pin()
  106. hapd.request("WPS_PIN any " + pin)
  107. dev[0].request("SET ignore_old_scan_res 1")
  108. dev[0].dump_monitor()
  109. dev[0].request("WPS_PIN any " + pin)
  110. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  111. if ev is None:
  112. raise Exception("Association with the AP timed out")
  113. status = dev[0].get_status()
  114. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  115. raise Exception("Not fully connected")
  116. if status['ssid'] != ssid:
  117. raise Exception("Unexpected SSID")
  118. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  119. raise Exception("Unexpected encryption configuration")
  120. if status['key_mgmt'] != 'WPA2-PSK':
  121. raise Exception("Unexpected key_mgmt")
  122. def test_ap_wps_reg_connect(dev, apdev):
  123. """WPS registrar using AP PIN to connect"""
  124. ssid = "test-wps-reg-ap-pin"
  125. appin = "12345670"
  126. hostapd.add_ap(apdev[0]['ifname'],
  127. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  128. "wpa_passphrase": "12345678", "wpa": "2",
  129. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  130. "ap_pin": appin})
  131. logger.info("WPS provisioning step")
  132. dev[0].request("SET ignore_old_scan_res 1")
  133. dev[0].dump_monitor()
  134. dev[0].wps_reg(apdev[0]['bssid'], appin)
  135. status = dev[0].get_status()
  136. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  137. raise Exception("Not fully connected")
  138. if status['ssid'] != ssid:
  139. raise Exception("Unexpected SSID")
  140. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  141. raise Exception("Unexpected encryption configuration")
  142. if status['key_mgmt'] != 'WPA2-PSK':
  143. raise Exception("Unexpected key_mgmt")
  144. def test_ap_wps_reg_config(dev, apdev):
  145. """WPS registrar configuring and AP using AP PIN"""
  146. ssid = "test-wps-init-ap-pin"
  147. appin = "12345670"
  148. hostapd.add_ap(apdev[0]['ifname'],
  149. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  150. "ap_pin": appin})
  151. logger.info("WPS configuration step")
  152. dev[0].request("SET ignore_old_scan_res 1")
  153. dev[0].dump_monitor()
  154. new_ssid = "wps-new-ssid"
  155. new_passphrase = "1234567890"
  156. dev[0].wps_reg(apdev[0]['bssid'], appin, new_ssid, "WPA2PSK", "CCMP",
  157. new_passphrase)
  158. status = dev[0].get_status()
  159. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  160. raise Exception("Not fully connected")
  161. if status['ssid'] != new_ssid:
  162. raise Exception("Unexpected SSID")
  163. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  164. raise Exception("Unexpected encryption configuration")
  165. if status['key_mgmt'] != 'WPA2-PSK':
  166. raise Exception("Unexpected key_mgmt")
  167. def test_ap_wps_setup_locked(dev, apdev):
  168. """WPS registrar locking up AP setup on AP PIN failures"""
  169. ssid = "test-wps-incorrect-ap-pin"
  170. appin = "12345670"
  171. hostapd.add_ap(apdev[0]['ifname'],
  172. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  173. "wpa_passphrase": "12345678", "wpa": "2",
  174. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  175. "ap_pin": appin})
  176. dev[0].request("SET ignore_old_scan_res 1")
  177. new_ssid = "wps-new-ssid-test"
  178. new_passphrase = "1234567890"
  179. ap_setup_locked=False
  180. for pin in ["55554444", "1234", "12345678", "00000000", "11111111"]:
  181. dev[0].dump_monitor()
  182. logger.info("Try incorrect AP PIN - attempt " + pin)
  183. dev[0].wps_reg(apdev[0]['bssid'], pin, new_ssid, "WPA2PSK",
  184. "CCMP", new_passphrase, no_wait=True)
  185. ev = dev[0].wait_event(["WPS-FAIL", "CTRL-EVENT-CONNECTED"])
  186. if ev is None:
  187. raise Exception("Timeout on receiving WPS operation failure event")
  188. if "CTRL-EVENT-CONNECTED" in ev:
  189. raise Exception("Unexpected connection")
  190. if "config_error=15" in ev:
  191. logger.info("AP Setup Locked")
  192. ap_setup_locked=True
  193. elif "config_error=18" not in ev:
  194. raise Exception("config_error=18 not reported")
  195. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
  196. if ev is None:
  197. raise Exception("Timeout on disconnection event")
  198. time.sleep(0.1)
  199. if not ap_setup_locked:
  200. raise Exception("AP setup was not locked")
  201. time.sleep(0.5)
  202. dev[0].dump_monitor()
  203. logger.info("WPS provisioning step")
  204. pin = dev[0].wps_read_pin()
  205. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  206. hapd.request("WPS_PIN any " + pin)
  207. dev[0].request("WPS_PIN any " + pin)
  208. ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=30)
  209. if ev is None:
  210. raise Exception("WPS success was not reported")
  211. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  212. if ev is None:
  213. raise Exception("Association with the AP timed out")
  214. def test_ap_wps_pbc_overlap_2ap(dev, apdev):
  215. """WPS PBC session overlap with two active APs"""
  216. hostapd.add_ap(apdev[0]['ifname'],
  217. { "ssid": "wps1", "eap_server": "1", "wps_state": "2",
  218. "wpa_passphrase": "12345678", "wpa": "2",
  219. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  220. "wps_independent": "1"})
  221. hostapd.add_ap(apdev[1]['ifname'],
  222. { "ssid": "wps2", "eap_server": "1", "wps_state": "2",
  223. "wpa_passphrase": "123456789", "wpa": "2",
  224. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  225. "wps_independent": "1"})
  226. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  227. hapd.request("WPS_PBC")
  228. hapd2 = hostapd.Hostapd(apdev[1]['ifname'])
  229. hapd2.request("WPS_PBC")
  230. logger.info("WPS provisioning step")
  231. dev[0].dump_monitor()
  232. dev[0].request("WPS_PBC")
  233. ev = dev[0].wait_event(["WPS-OVERLAP-DETECTED"], timeout=15)
  234. if ev is None:
  235. raise Exception("PBC session overlap not detected")
  236. def test_ap_wps_pbc_overlap_2sta(dev, apdev):
  237. """WPS PBC session overlap with two active STAs"""
  238. ssid = "test-wps-pbc-overlap"
  239. hostapd.add_ap(apdev[0]['ifname'],
  240. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  241. "wpa_passphrase": "12345678", "wpa": "2",
  242. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
  243. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  244. logger.info("WPS provisioning step")
  245. hapd.request("WPS_PBC")
  246. dev[0].request("SET ignore_old_scan_res 1")
  247. dev[1].request("SET ignore_old_scan_res 1")
  248. dev[0].dump_monitor()
  249. dev[1].dump_monitor()
  250. dev[0].request("WPS_PBC")
  251. dev[1].request("WPS_PBC")
  252. ev = dev[0].wait_event(["WPS-M2D"], timeout=15)
  253. if ev is None:
  254. raise Exception("PBC session overlap not detected (dev0)")
  255. if "config_error=12" not in ev:
  256. raise Exception("PBC session overlap not correctly reported (dev0)")
  257. ev = dev[1].wait_event(["WPS-M2D"], timeout=15)
  258. if ev is None:
  259. raise Exception("PBC session overlap not detected (dev1)")
  260. if "config_error=12" not in ev:
  261. raise Exception("PBC session overlap not correctly reported (dev1)")
  262. def test_ap_wps_er_add_enrollee(dev, apdev):
  263. """WPS ER configuring AP and adding a new enrollee using PIN"""
  264. ssid = "wps-er-add-enrollee"
  265. ap_pin = "12345670"
  266. ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
  267. hostapd.add_ap(apdev[0]['ifname'],
  268. { "ssid": ssid, "eap_server": "1", "wps_state": "1",
  269. "device_name": "Wireless AP", "manufacturer": "Company",
  270. "model_name": "WAP", "model_number": "123",
  271. "serial_number": "12345", "device_type": "6-0050F204-1",
  272. "os_version": "01020300",
  273. "config_methods": "label push_button",
  274. "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"})
  275. logger.info("WPS configuration step")
  276. new_passphrase = "1234567890"
  277. dev[0].dump_monitor()
  278. dev[0].request("SET ignore_old_scan_res 1")
  279. dev[0].wps_reg(apdev[0]['bssid'], ap_pin, ssid, "WPA2PSK", "CCMP",
  280. new_passphrase)
  281. status = dev[0].get_status()
  282. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  283. raise Exception("Not fully connected")
  284. if status['ssid'] != ssid:
  285. raise Exception("Unexpected SSID")
  286. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  287. raise Exception("Unexpected encryption configuration")
  288. if status['key_mgmt'] != 'WPA2-PSK':
  289. raise Exception("Unexpected key_mgmt")
  290. logger.info("Start ER")
  291. dev[0].request("WPS_ER_START ifname=lo")
  292. ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15)
  293. if ev is None:
  294. raise Exception("AP discovery timed out")
  295. if ap_uuid not in ev:
  296. raise Exception("Expected AP UUID not found")
  297. logger.info("Learn AP configuration through UPnP")
  298. dev[0].dump_monitor()
  299. dev[0].request("WPS_ER_LEARN " + ap_uuid + " " + ap_pin)
  300. ev = dev[0].wait_event(["WPS-ER-AP-SETTINGS"], timeout=15)
  301. if ev is None:
  302. raise Exception("AP learn timed out")
  303. if ap_uuid not in ev:
  304. raise Exception("Expected AP UUID not in settings")
  305. if "ssid=" + ssid not in ev:
  306. raise Exception("Expected SSID not in settings")
  307. if "key=" + new_passphrase not in ev:
  308. raise Exception("Expected passphrase not in settings")
  309. logger.info("Add Enrollee using ER")
  310. pin = dev[1].wps_read_pin()
  311. dev[0].dump_monitor()
  312. dev[0].request("WPS_ER_PIN any " + pin + " " + dev[1].p2p_interface_addr())
  313. dev[1].request("SET ignore_old_scan_res 1")
  314. dev[1].dump_monitor()
  315. dev[1].request("WPS_PIN any " + pin)
  316. ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=30)
  317. if ev is None:
  318. raise Exception("Enrollee did not report success")
  319. ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
  320. if ev is None:
  321. raise Exception("Association with the AP timed out")
  322. ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
  323. if ev is None:
  324. raise Exception("WPS ER did not report success")
  325. hwsim_utils.test_connectivity_sta(dev[0], dev[1])
  326. def test_ap_wps_er_add_enrollee_pbc(dev, apdev):
  327. """WPS ER connected to AP and adding a new enrollee using PBC"""
  328. ssid = "wps-er-add-enrollee-pbc"
  329. ap_pin = "12345670"
  330. ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
  331. hostapd.add_ap(apdev[0]['ifname'],
  332. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  333. "wpa_passphrase": "12345678", "wpa": "2",
  334. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  335. "device_name": "Wireless AP", "manufacturer": "Company",
  336. "model_name": "WAP", "model_number": "123",
  337. "serial_number": "12345", "device_type": "6-0050F204-1",
  338. "os_version": "01020300",
  339. "config_methods": "label push_button",
  340. "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"})
  341. logger.info("Learn AP configuration")
  342. dev[0].dump_monitor()
  343. dev[0].request("SET ignore_old_scan_res 1")
  344. dev[0].wps_reg(apdev[0]['bssid'], ap_pin)
  345. status = dev[0].get_status()
  346. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  347. raise Exception("Not fully connected")
  348. logger.info("Start ER")
  349. dev[0].request("WPS_ER_START ifname=lo")
  350. ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15)
  351. if ev is None:
  352. raise Exception("AP discovery timed out")
  353. if ap_uuid not in ev:
  354. raise Exception("Expected AP UUID not found")
  355. logger.info("Use learned network configuration on ER")
  356. dev[0].request("WPS_ER_SET_CONFIG " + ap_uuid + " 0")
  357. logger.info("Add Enrollee using ER and PBC")
  358. dev[0].dump_monitor()
  359. enrollee = dev[1].p2p_interface_addr()
  360. dev[1].request("SET ignore_old_scan_res 1")
  361. dev[1].dump_monitor()
  362. dev[1].request("WPS_PBC")
  363. ev = dev[0].wait_event(["WPS-ER-ENROLLEE-ADD"], timeout=15)
  364. if ev is None:
  365. raise Exception("Enrollee discovery timed out")
  366. if enrollee not in ev:
  367. raise Exception("Expected Enrollee not found")
  368. dev[0].request("WPS_ER_PBC " + enrollee)
  369. ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=15)
  370. if ev is None:
  371. raise Exception("Enrollee did not report success")
  372. ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
  373. if ev is None:
  374. raise Exception("Association with the AP timed out")
  375. ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
  376. if ev is None:
  377. raise Exception("WPS ER did not report success")
  378. hwsim_utils.test_connectivity_sta(dev[0], dev[1])
  379. def test_ap_wps_fragmentation(dev, apdev):
  380. """WPS with fragmentation in EAP-WSC and mixed mode WPA+WPA2"""
  381. ssid = "test-wps-fragmentation"
  382. hostapd.add_ap(apdev[0]['ifname'],
  383. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  384. "wpa_passphrase": "12345678", "wpa": "3",
  385. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  386. "wpa_pairwise": "TKIP",
  387. "fragment_size": "50" })
  388. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  389. logger.info("WPS provisioning step")
  390. hapd.request("WPS_PBC")
  391. dev[0].request("SET ignore_old_scan_res 1")
  392. dev[0].dump_monitor()
  393. dev[0].request("SET wps_fragment_size 50")
  394. dev[0].request("WPS_PBC")
  395. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  396. if ev is None:
  397. raise Exception("Association with the AP timed out")
  398. status = dev[0].get_status()
  399. if status['wpa_state'] != 'COMPLETED':
  400. raise Exception("Not fully connected")
  401. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'TKIP':
  402. raise Exception("Unexpected encryption configuration")
  403. if status['key_mgmt'] != 'WPA2-PSK':
  404. raise Exception("Unexpected key_mgmt")
  405. def test_ap_wps_new_version_sta(dev, apdev):
  406. """WPS compatibility with new version number on the station"""
  407. ssid = "test-wps-ver"
  408. hostapd.add_ap(apdev[0]['ifname'],
  409. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  410. "wpa_passphrase": "12345678", "wpa": "2",
  411. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
  412. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  413. logger.info("WPS provisioning step")
  414. hapd.request("WPS_PBC")
  415. dev[0].request("SET ignore_old_scan_res 1")
  416. dev[0].dump_monitor()
  417. dev[0].request("SET wps_version_number 0x43")
  418. dev[0].request("WPS_PBC")
  419. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  420. if ev is None:
  421. raise Exception("Association with the AP timed out")
  422. def test_ap_wps_new_version_ap(dev, apdev):
  423. """WPS compatibility with new version number on the AP"""
  424. ssid = "test-wps-ver"
  425. hostapd.add_ap(apdev[0]['ifname'],
  426. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  427. "wpa_passphrase": "12345678", "wpa": "2",
  428. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
  429. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  430. logger.info("WPS provisioning step")
  431. if "FAIL" in hapd.request("SET wps_version_number 0x43"):
  432. raise Exception("Failed to enable test functionality")
  433. hapd.request("WPS_PBC")
  434. dev[0].request("SET ignore_old_scan_res 1")
  435. dev[0].dump_monitor()
  436. dev[0].request("WPS_PBC")
  437. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  438. hapd.request("SET wps_version_number 0x20")
  439. if ev is None:
  440. raise Exception("Association with the AP timed out")