test_ap_eap.py 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. #!/usr/bin/python
  2. #
  3. # WPA2-Enterprise tests
  4. # Copyright (c) 2013-2014, 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 os.path
  13. import hwsim_utils
  14. import hostapd
  15. def eap_connect(dev, ap, method, identity, anonymous_identity=None,
  16. password=None,
  17. phase1=None, phase2=None, ca_cert=None,
  18. domain_suffix_match=None, password_hex=None,
  19. client_cert=None, private_key=None, sha256=False,
  20. fragment_size=None, expect_failure=False,
  21. local_error_report=False,
  22. ca_cert2=None, client_cert2=None, private_key2=None,
  23. pac_file=None, subject_match=None, altsubject_match=None,
  24. private_key_passwd=None):
  25. hapd = hostapd.Hostapd(ap['ifname'])
  26. id = dev.connect("test-wpa2-eap", key_mgmt="WPA-EAP WPA-EAP-SHA256",
  27. eap=method, identity=identity,
  28. anonymous_identity=anonymous_identity,
  29. password=password, phase1=phase1, phase2=phase2,
  30. ca_cert=ca_cert, domain_suffix_match=domain_suffix_match,
  31. wait_connect=False, scan_freq="2412",
  32. password_hex=password_hex,
  33. client_cert=client_cert, private_key=private_key,
  34. ieee80211w="1", fragment_size=fragment_size,
  35. ca_cert2=ca_cert2, client_cert2=client_cert2,
  36. private_key2=private_key2, pac_file=pac_file,
  37. subject_match=subject_match,
  38. altsubject_match=altsubject_match,
  39. private_key_passwd=private_key_passwd)
  40. eap_check_auth(dev, method, True, sha256=sha256,
  41. expect_failure=expect_failure,
  42. local_error_report=local_error_report)
  43. if expect_failure:
  44. return id
  45. ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
  46. if ev is None:
  47. raise Exception("No connection event received from hostapd")
  48. return id
  49. def eap_check_auth(dev, method, initial, rsn=True, sha256=False,
  50. expect_failure=False, local_error_report=False):
  51. ev = dev.wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=10)
  52. if ev is None:
  53. raise Exception("Association and EAP start timed out")
  54. ev = dev.wait_event(["CTRL-EVENT-EAP-METHOD"], timeout=10)
  55. if ev is None:
  56. raise Exception("EAP method selection timed out")
  57. if method not in ev:
  58. raise Exception("Unexpected EAP method")
  59. if expect_failure:
  60. ev = dev.wait_event(["CTRL-EVENT-EAP-FAILURE"])
  61. if ev is None:
  62. raise Exception("EAP failure timed out")
  63. ev = dev.wait_event(["CTRL-EVENT-DISCONNECTED"])
  64. if ev is None:
  65. raise Exception("Disconnection timed out")
  66. if not local_error_report:
  67. if "reason=23" not in ev:
  68. raise Exception("Proper reason code for disconnection not reported")
  69. return
  70. ev = dev.wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
  71. if ev is None:
  72. raise Exception("EAP success timed out")
  73. if initial:
  74. ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
  75. else:
  76. ev = dev.wait_event(["WPA: Key negotiation completed"], timeout=10)
  77. if ev is None:
  78. raise Exception("Association with the AP timed out")
  79. status = dev.get_status()
  80. if status["wpa_state"] != "COMPLETED":
  81. raise Exception("Connection not completed")
  82. if status["suppPortStatus"] != "Authorized":
  83. raise Exception("Port not authorized")
  84. if method not in status["selectedMethod"]:
  85. raise Exception("Incorrect EAP method status")
  86. if sha256:
  87. e = "WPA2-EAP-SHA256"
  88. elif rsn:
  89. e = "WPA2/IEEE 802.1X/EAP"
  90. else:
  91. e = "WPA/IEEE 802.1X/EAP"
  92. if status["key_mgmt"] != e:
  93. raise Exception("Unexpected key_mgmt status: " + status["key_mgmt"])
  94. def eap_reauth(dev, method, rsn=True, sha256=False):
  95. dev.request("REAUTHENTICATE")
  96. eap_check_auth(dev, method, False, rsn=rsn, sha256=sha256)
  97. def test_ap_wpa2_eap_sim(dev, apdev):
  98. """WPA2-Enterprise connection using EAP-SIM"""
  99. if not os.path.exists("/tmp/hlr_auc_gw.sock"):
  100. logger.info("No hlr_auc_gw available");
  101. return "skip"
  102. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  103. hostapd.add_ap(apdev[0]['ifname'], params)
  104. eap_connect(dev[0], apdev[0], "SIM", "1232010000000000",
  105. password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581")
  106. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  107. eap_reauth(dev[0], "SIM")
  108. logger.info("Negative test with incorrect key")
  109. dev[0].request("REMOVE_NETWORK all")
  110. eap_connect(dev[0], apdev[0], "SIM", "1232010000000000",
  111. password="ffdca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581",
  112. expect_failure=True)
  113. def test_ap_wpa2_eap_aka(dev, apdev):
  114. """WPA2-Enterprise connection using EAP-AKA"""
  115. if not os.path.exists("/tmp/hlr_auc_gw.sock"):
  116. logger.info("No hlr_auc_gw available");
  117. return "skip"
  118. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  119. hostapd.add_ap(apdev[0]['ifname'], params)
  120. eap_connect(dev[0], apdev[0], "AKA", "0232010000000000",
  121. password="90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581:000000000123")
  122. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  123. eap_reauth(dev[0], "AKA")
  124. logger.info("Negative test with incorrect key")
  125. dev[0].request("REMOVE_NETWORK all")
  126. eap_connect(dev[0], apdev[0], "AKA", "0232010000000000",
  127. password="ffdca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581:000000000123",
  128. expect_failure=True)
  129. def test_ap_wpa2_eap_aka_prime(dev, apdev):
  130. """WPA2-Enterprise connection using EAP-AKA'"""
  131. if not os.path.exists("/tmp/hlr_auc_gw.sock"):
  132. logger.info("No hlr_auc_gw available");
  133. return "skip"
  134. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  135. hostapd.add_ap(apdev[0]['ifname'], params)
  136. eap_connect(dev[0], apdev[0], "AKA'", "6555444333222111",
  137. password="5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123")
  138. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  139. eap_reauth(dev[0], "AKA'")
  140. logger.info("Negative test with incorrect key")
  141. dev[0].request("REMOVE_NETWORK all")
  142. eap_connect(dev[0], apdev[0], "AKA'", "6555444333222111",
  143. password="ff22250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123",
  144. expect_failure=True)
  145. def test_ap_wpa2_eap_ttls_pap(dev, apdev):
  146. """WPA2-Enterprise connection using EAP-TTLS/PAP"""
  147. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  148. hostapd.add_ap(apdev[0]['ifname'], params)
  149. eap_connect(dev[0], apdev[0], "TTLS", "pap user",
  150. anonymous_identity="ttls", password="password",
  151. ca_cert="auth_serv/ca.pem", phase2="auth=PAP",
  152. subject_match="/C=FI/O=w1.fi/CN=server.w1.fi",
  153. altsubject_match="EMAIL:noone@example.com;DNS:server.w1.fi;URI:http://example.com/")
  154. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  155. eap_reauth(dev[0], "TTLS")
  156. def test_ap_wpa2_eap_ttls_chap(dev, apdev):
  157. """WPA2-Enterprise connection using EAP-TTLS/CHAP"""
  158. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  159. hostapd.add_ap(apdev[0]['ifname'], params)
  160. eap_connect(dev[0], apdev[0], "TTLS", "chap user",
  161. anonymous_identity="ttls", password="password",
  162. ca_cert="auth_serv/ca.der", phase2="auth=CHAP")
  163. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  164. eap_reauth(dev[0], "TTLS")
  165. def test_ap_wpa2_eap_ttls_mschap(dev, apdev):
  166. """WPA2-Enterprise connection using EAP-TTLS/MSCHAP"""
  167. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  168. hostapd.add_ap(apdev[0]['ifname'], params)
  169. eap_connect(dev[0], apdev[0], "TTLS", "mschap user",
  170. anonymous_identity="ttls", password="password",
  171. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAP",
  172. domain_suffix_match="server.w1.fi")
  173. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  174. eap_reauth(dev[0], "TTLS")
  175. dev[0].request("REMOVE_NETWORK all")
  176. eap_connect(dev[0], apdev[0], "TTLS", "mschap user",
  177. anonymous_identity="ttls", password="password",
  178. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAP",
  179. fragment_size="200")
  180. def test_ap_wpa2_eap_ttls_mschapv2(dev, apdev):
  181. """WPA2-Enterprise connection using EAP-TTLS/MSCHAPv2"""
  182. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  183. hostapd.add_ap(apdev[0]['ifname'], params)
  184. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  185. eap_connect(dev[0], apdev[0], "TTLS", "DOMAIN\mschapv2 user",
  186. anonymous_identity="ttls", password="password",
  187. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2",
  188. domain_suffix_match="w1.fi")
  189. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  190. sta1 = hapd.get_sta(dev[0].p2p_interface_addr())
  191. eapol1 = hapd.get_sta(dev[0].p2p_interface_addr(), info="eapol")
  192. eap_reauth(dev[0], "TTLS")
  193. sta2 = hapd.get_sta(dev[0].p2p_interface_addr())
  194. eapol2 = hapd.get_sta(dev[0].p2p_interface_addr(), info="eapol")
  195. if int(sta2['dot1xAuthEapolFramesRx']) <= int(sta1['dot1xAuthEapolFramesRx']):
  196. raise Exception("dot1xAuthEapolFramesRx did not increase")
  197. if int(eapol2['authAuthEapStartsWhileAuthenticated']) < 1:
  198. raise Exception("authAuthEapStartsWhileAuthenticated did not increase")
  199. if int(eapol2['backendAuthSuccesses']) <= int(eapol1['backendAuthSuccesses']):
  200. raise Exception("backendAuthSuccesses did not increase")
  201. logger.info("Password as hash value")
  202. dev[0].request("REMOVE_NETWORK all")
  203. eap_connect(dev[0], apdev[0], "TTLS", "DOMAIN\mschapv2 user",
  204. anonymous_identity="ttls",
  205. password_hex="hash:8846f7eaee8fb117ad06bdd830b7586c",
  206. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2")
  207. logger.info("Negative test with incorrect password")
  208. dev[0].request("REMOVE_NETWORK all")
  209. eap_connect(dev[0], apdev[0], "TTLS", "DOMAIN\mschapv2 user",
  210. anonymous_identity="ttls", password="password1",
  211. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2",
  212. expect_failure=True)
  213. def test_ap_wpa2_eap_ttls_eap_gtc(dev, apdev):
  214. """WPA2-Enterprise connection using EAP-TTLS/EAP-GTC"""
  215. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  216. hostapd.add_ap(apdev[0]['ifname'], params)
  217. eap_connect(dev[0], apdev[0], "TTLS", "user",
  218. anonymous_identity="ttls", password="password",
  219. ca_cert="auth_serv/ca.pem", phase2="autheap=GTC")
  220. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  221. eap_reauth(dev[0], "TTLS")
  222. def test_ap_wpa2_eap_ttls_eap_md5(dev, apdev):
  223. """WPA2-Enterprise connection using EAP-TTLS/EAP-MD5"""
  224. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  225. hostapd.add_ap(apdev[0]['ifname'], params)
  226. eap_connect(dev[0], apdev[0], "TTLS", "user",
  227. anonymous_identity="ttls", password="password",
  228. ca_cert="auth_serv/ca.pem", phase2="autheap=MD5")
  229. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  230. eap_reauth(dev[0], "TTLS")
  231. def test_ap_wpa2_eap_ttls_eap_mschapv2(dev, apdev):
  232. """WPA2-Enterprise connection using EAP-TTLS/EAP-MSCHAPv2"""
  233. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  234. hostapd.add_ap(apdev[0]['ifname'], params)
  235. eap_connect(dev[0], apdev[0], "TTLS", "user",
  236. anonymous_identity="ttls", password="password",
  237. ca_cert="auth_serv/ca.pem", phase2="autheap=MSCHAPV2")
  238. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  239. eap_reauth(dev[0], "TTLS")
  240. logger.info("Negative test with incorrect password")
  241. dev[0].request("REMOVE_NETWORK all")
  242. eap_connect(dev[0], apdev[0], "TTLS", "user",
  243. anonymous_identity="ttls", password="password1",
  244. ca_cert="auth_serv/ca.pem", phase2="autheap=MSCHAPV2",
  245. expect_failure=True)
  246. def test_ap_wpa2_eap_peap_eap_mschapv2(dev, apdev):
  247. """WPA2-Enterprise connection using EAP-PEAP/EAP-MSCHAPv2"""
  248. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  249. hostapd.add_ap(apdev[0]['ifname'], params)
  250. eap_connect(dev[0], apdev[0], "PEAP", "user",
  251. anonymous_identity="peap", password="password",
  252. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2")
  253. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  254. eap_reauth(dev[0], "PEAP")
  255. dev[0].request("REMOVE_NETWORK all")
  256. eap_connect(dev[0], apdev[0], "PEAP", "user",
  257. anonymous_identity="peap", password="password",
  258. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2",
  259. fragment_size="200")
  260. logger.info("Password as hash value")
  261. dev[0].request("REMOVE_NETWORK all")
  262. eap_connect(dev[0], apdev[0], "PEAP", "user",
  263. anonymous_identity="peap",
  264. password_hex="hash:8846f7eaee8fb117ad06bdd830b7586c",
  265. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2")
  266. logger.info("Negative test with incorrect password")
  267. dev[0].request("REMOVE_NETWORK all")
  268. eap_connect(dev[0], apdev[0], "PEAP", "user",
  269. anonymous_identity="peap", password="password1",
  270. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2",
  271. expect_failure=True)
  272. def test_ap_wpa2_eap_peap_crypto_binding(dev, apdev):
  273. """WPA2-Enterprise connection using EAP-PEAPv0/EAP-MSCHAPv2 and crypto binding"""
  274. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  275. hostapd.add_ap(apdev[0]['ifname'], params)
  276. eap_connect(dev[0], apdev[0], "PEAP", "user", password="password",
  277. ca_cert="auth_serv/ca.pem",
  278. phase1="peapver=0 crypto_binding=2",
  279. phase2="auth=MSCHAPV2")
  280. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  281. eap_reauth(dev[0], "PEAP")
  282. def test_ap_wpa2_eap_peap_eap_tls(dev, apdev):
  283. """WPA2-Enterprise connection using EAP-PEAP/EAP-TLS"""
  284. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  285. hostapd.add_ap(apdev[0]['ifname'], params)
  286. eap_connect(dev[0], apdev[0], "PEAP", "cert user",
  287. ca_cert="auth_serv/ca.pem", phase2="auth=TLS",
  288. ca_cert2="auth_serv/ca.pem",
  289. client_cert2="auth_serv/user.pem",
  290. private_key2="auth_serv/user.key")
  291. eap_reauth(dev[0], "PEAP")
  292. def test_ap_wpa2_eap_tls(dev, apdev):
  293. """WPA2-Enterprise connection using EAP-TLS"""
  294. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  295. hostapd.add_ap(apdev[0]['ifname'], params)
  296. eap_connect(dev[0], apdev[0], "TLS", "tls user", ca_cert="auth_serv/ca.pem",
  297. client_cert="auth_serv/user.pem",
  298. private_key="auth_serv/user.key")
  299. eap_reauth(dev[0], "TLS")
  300. def test_ap_wpa2_eap_tls_pkcs12(dev, apdev):
  301. """WPA2-Enterprise connection using EAP-TLS and PKCS#12"""
  302. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  303. hostapd.add_ap(apdev[0]['ifname'], params)
  304. eap_connect(dev[0], apdev[0], "TLS", "tls user", ca_cert="auth_serv/ca.pem",
  305. private_key="auth_serv/user.pkcs12",
  306. private_key_passwd="whatever")
  307. dev[0].request("REMOVE_NETWORK all")
  308. dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TLS",
  309. identity="tls user",
  310. ca_cert="auth_serv/ca.pem",
  311. private_key="auth_serv/user.pkcs12",
  312. wait_connect=False, scan_freq="2412")
  313. ev = dev[0].wait_event(["CTRL-REQ-PASSPHRASE"])
  314. if ev is None:
  315. raise Exception("Request for private key passphrase timed out")
  316. id = ev.split(':')[0].split('-')[-1]
  317. dev[0].request("CTRL-RSP-PASSPHRASE-" + id + ":whatever")
  318. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
  319. if ev is None:
  320. raise Exception("Connection timed out")
  321. def test_ap_wpa2_eap_tls_neg_incorrect_trust_root(dev, apdev):
  322. """WPA2-Enterprise negative test - incorrect trust root"""
  323. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  324. hostapd.add_ap(apdev[0]['ifname'], params)
  325. dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
  326. identity="DOMAIN\mschapv2 user", anonymous_identity="ttls",
  327. password="password", phase2="auth=MSCHAPV2",
  328. ca_cert="auth_serv/ca-incorrect.pem",
  329. wait_connect=False, scan_freq="2412")
  330. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=10)
  331. if ev is None:
  332. raise Exception("Association and EAP start timed out")
  333. ev = dev[0].wait_event(["CTRL-EVENT-EAP-METHOD"], timeout=10)
  334. if ev is None:
  335. raise Exception("EAP method selection timed out")
  336. if "TTLS" not in ev:
  337. raise Exception("Unexpected EAP method")
  338. ev = dev[0].wait_event(["CTRL-EVENT-EAP-TLS-CERT-ERROR",
  339. "CTRL-EVENT-EAP-SUCCESS",
  340. "CTRL-EVENT-EAP-FAILURE",
  341. "CTRL-EVENT-CONNECTED",
  342. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  343. if ev is None:
  344. raise Exception("EAP result timed out")
  345. if "CTRL-EVENT-EAP-TLS-CERT-ERROR" not in ev:
  346. raise Exception("TLS certificate error not reported")
  347. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS",
  348. "CTRL-EVENT-EAP-FAILURE",
  349. "CTRL-EVENT-CONNECTED",
  350. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  351. if ev is None:
  352. raise Exception("EAP result(2) timed out")
  353. if "CTRL-EVENT-EAP-FAILURE" not in ev:
  354. raise Exception("EAP failure not reported")
  355. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED",
  356. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  357. if ev is None:
  358. raise Exception("EAP result(3) timed out")
  359. if "CTRL-EVENT-DISCONNECTED" not in ev:
  360. raise Exception("Disconnection not reported")
  361. ev = dev[0].wait_event(["CTRL-EVENT-SSID-TEMP-DISABLED"], timeout=10)
  362. if ev is None:
  363. raise Exception("Network block disabling not reported")
  364. def test_ap_wpa2_eap_tls_neg_suffix_match(dev, apdev):
  365. """WPA2-Enterprise negative test - domain suffix mismatch"""
  366. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  367. hostapd.add_ap(apdev[0]['ifname'], params)
  368. dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
  369. identity="DOMAIN\mschapv2 user", anonymous_identity="ttls",
  370. password="password", phase2="auth=MSCHAPV2",
  371. ca_cert="auth_serv/ca.pem",
  372. domain_suffix_match="incorrect.example.com",
  373. wait_connect=False, scan_freq="2412")
  374. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=10)
  375. if ev is None:
  376. raise Exception("Association and EAP start timed out")
  377. ev = dev[0].wait_event(["CTRL-EVENT-EAP-METHOD"], timeout=10)
  378. if ev is None:
  379. raise Exception("EAP method selection timed out")
  380. if "TTLS" not in ev:
  381. raise Exception("Unexpected EAP method")
  382. ev = dev[0].wait_event(["CTRL-EVENT-EAP-TLS-CERT-ERROR",
  383. "CTRL-EVENT-EAP-SUCCESS",
  384. "CTRL-EVENT-EAP-FAILURE",
  385. "CTRL-EVENT-CONNECTED",
  386. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  387. if ev is None:
  388. raise Exception("EAP result timed out")
  389. if "CTRL-EVENT-EAP-TLS-CERT-ERROR" not in ev:
  390. raise Exception("TLS certificate error not reported")
  391. if "Domain suffix mismatch" not in ev:
  392. raise Exception("Domain suffix mismatch not reported")
  393. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS",
  394. "CTRL-EVENT-EAP-FAILURE",
  395. "CTRL-EVENT-CONNECTED",
  396. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  397. if ev is None:
  398. raise Exception("EAP result(2) timed out")
  399. if "CTRL-EVENT-EAP-FAILURE" not in ev:
  400. raise Exception("EAP failure not reported")
  401. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED",
  402. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  403. if ev is None:
  404. raise Exception("EAP result(3) timed out")
  405. if "CTRL-EVENT-DISCONNECTED" not in ev:
  406. raise Exception("Disconnection not reported")
  407. ev = dev[0].wait_event(["CTRL-EVENT-SSID-TEMP-DISABLED"], timeout=10)
  408. if ev is None:
  409. raise Exception("Network block disabling not reported")
  410. def test_ap_wpa2_eap_tls_neg_subject_match(dev, apdev):
  411. """WPA2-Enterprise negative test - subject mismatch"""
  412. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  413. hostapd.add_ap(apdev[0]['ifname'], params)
  414. dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
  415. identity="DOMAIN\mschapv2 user", anonymous_identity="ttls",
  416. password="password", phase2="auth=MSCHAPV2",
  417. ca_cert="auth_serv/ca.pem",
  418. subject_match="/C=FI/O=w1.fi/CN=example.com",
  419. wait_connect=False, scan_freq="2412")
  420. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=10)
  421. if ev is None:
  422. raise Exception("Association and EAP start timed out")
  423. ev = dev[0].wait_event(["CTRL-EVENT-EAP-METHOD"], timeout=10)
  424. if ev is None:
  425. raise Exception("EAP method selection timed out")
  426. if "TTLS" not in ev:
  427. raise Exception("Unexpected EAP method")
  428. ev = dev[0].wait_event(["CTRL-EVENT-EAP-TLS-CERT-ERROR",
  429. "CTRL-EVENT-EAP-SUCCESS",
  430. "CTRL-EVENT-EAP-FAILURE",
  431. "CTRL-EVENT-CONNECTED",
  432. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  433. if ev is None:
  434. raise Exception("EAP result timed out")
  435. if "CTRL-EVENT-EAP-TLS-CERT-ERROR" not in ev:
  436. raise Exception("TLS certificate error not reported")
  437. if "Subject mismatch" not in ev:
  438. raise Exception("Subject mismatch not reported")
  439. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS",
  440. "CTRL-EVENT-EAP-FAILURE",
  441. "CTRL-EVENT-CONNECTED",
  442. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  443. if ev is None:
  444. raise Exception("EAP result(2) timed out")
  445. if "CTRL-EVENT-EAP-FAILURE" not in ev:
  446. raise Exception("EAP failure not reported")
  447. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED",
  448. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  449. if ev is None:
  450. raise Exception("EAP result(3) timed out")
  451. if "CTRL-EVENT-DISCONNECTED" not in ev:
  452. raise Exception("Disconnection not reported")
  453. ev = dev[0].wait_event(["CTRL-EVENT-SSID-TEMP-DISABLED"], timeout=10)
  454. if ev is None:
  455. raise Exception("Network block disabling not reported")
  456. def test_ap_wpa2_eap_tls_neg_altsubject_match(dev, apdev):
  457. """WPA2-Enterprise negative test - altsubject mismatch"""
  458. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  459. hostapd.add_ap(apdev[0]['ifname'], params)
  460. dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
  461. identity="DOMAIN\mschapv2 user", anonymous_identity="ttls",
  462. password="password", phase2="auth=MSCHAPV2",
  463. ca_cert="auth_serv/ca.pem",
  464. altsubject_match="incorrect.example.com",
  465. wait_connect=False, scan_freq="2412")
  466. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=10)
  467. if ev is None:
  468. raise Exception("Association and EAP start timed out")
  469. ev = dev[0].wait_event(["CTRL-EVENT-EAP-METHOD"], timeout=10)
  470. if ev is None:
  471. raise Exception("EAP method selection timed out")
  472. if "TTLS" not in ev:
  473. raise Exception("Unexpected EAP method")
  474. ev = dev[0].wait_event(["CTRL-EVENT-EAP-TLS-CERT-ERROR",
  475. "CTRL-EVENT-EAP-SUCCESS",
  476. "CTRL-EVENT-EAP-FAILURE",
  477. "CTRL-EVENT-CONNECTED",
  478. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  479. if ev is None:
  480. raise Exception("EAP result timed out")
  481. if "CTRL-EVENT-EAP-TLS-CERT-ERROR" not in ev:
  482. raise Exception("TLS certificate error not reported")
  483. if "AltSubject mismatch" not in ev:
  484. raise Exception("altsubject mismatch not reported")
  485. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS",
  486. "CTRL-EVENT-EAP-FAILURE",
  487. "CTRL-EVENT-CONNECTED",
  488. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  489. if ev is None:
  490. raise Exception("EAP result(2) timed out")
  491. if "CTRL-EVENT-EAP-FAILURE" not in ev:
  492. raise Exception("EAP failure not reported")
  493. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED",
  494. "CTRL-EVENT-DISCONNECTED"], timeout=10)
  495. if ev is None:
  496. raise Exception("EAP result(3) timed out")
  497. if "CTRL-EVENT-DISCONNECTED" not in ev:
  498. raise Exception("Disconnection not reported")
  499. ev = dev[0].wait_event(["CTRL-EVENT-SSID-TEMP-DISABLED"], timeout=10)
  500. if ev is None:
  501. raise Exception("Network block disabling not reported")
  502. def test_ap_wpa2_eap_ttls_server_cert_hash(dev, apdev):
  503. """WPA2-Enterprise connection using EAP-TTLS and server certificate hash"""
  504. srv_cert_hash = "0a3f81f63569226657a069855bb13f3b922670437a2b87585a4734f70ac7315b"
  505. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  506. hostapd.add_ap(apdev[0]['ifname'], params)
  507. dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
  508. identity="probe", ca_cert="probe://",
  509. wait_connect=False, scan_freq="2412")
  510. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=10)
  511. if ev is None:
  512. raise Exception("Association and EAP start timed out")
  513. ev = dev[0].wait_event(["CTRL-EVENT-EAP-PEER-CERT depth=0"], timeout=10)
  514. if ev is None:
  515. raise Exception("No peer server certificate event seen")
  516. if "hash=" + srv_cert_hash not in ev:
  517. raise Exception("Expected server certificate hash not reported")
  518. ev = dev[0].wait_event(["CTRL-EVENT-EAP-TLS-CERT-ERROR"], timeout=10)
  519. if ev is None:
  520. raise Exception("EAP result timed out")
  521. if "Server certificate chain probe" not in ev:
  522. raise Exception("Server certificate probe not reported")
  523. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
  524. if ev is None:
  525. raise Exception("Disconnection event not seen")
  526. dev[0].request("REMOVE_NETWORK all")
  527. dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
  528. identity="DOMAIN\mschapv2 user", anonymous_identity="ttls",
  529. password="password", phase2="auth=MSCHAPV2",
  530. ca_cert="hash://server/sha256/5a1bc1296205e6fdbe3979728efe3920798885c1c4590b5f90f43222d239ca6a",
  531. wait_connect=False, scan_freq="2412")
  532. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=10)
  533. if ev is None:
  534. raise Exception("Association and EAP start timed out")
  535. ev = dev[0].wait_event(["CTRL-EVENT-EAP-TLS-CERT-ERROR"], timeout=10)
  536. if ev is None:
  537. raise Exception("EAP result timed out")
  538. if "Server certificate mismatch" not in ev:
  539. raise Exception("Server certificate mismatch not reported")
  540. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
  541. if ev is None:
  542. raise Exception("Disconnection event not seen")
  543. dev[0].request("REMOVE_NETWORK all")
  544. eap_connect(dev[0], apdev[0], "TTLS", "DOMAIN\mschapv2 user",
  545. anonymous_identity="ttls", password="password",
  546. ca_cert="hash://server/sha256/" + srv_cert_hash,
  547. phase2="auth=MSCHAPV2")
  548. def test_ap_wpa2_eap_pwd(dev, apdev):
  549. """WPA2-Enterprise connection using EAP-pwd"""
  550. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  551. hostapd.add_ap(apdev[0]['ifname'], params)
  552. eap_connect(dev[0], apdev[0], "PWD", "pwd user", password="secret password")
  553. eap_reauth(dev[0], "PWD")
  554. dev[0].request("REMOVE_NETWORK all")
  555. eap_connect(dev[0], apdev[0], "PWD", "pwd user", password="secret password",
  556. fragment_size="90")
  557. logger.info("Negative test with incorrect password")
  558. dev[0].request("REMOVE_NETWORK all")
  559. eap_connect(dev[0], apdev[0], "PWD", "pwd user", password="secret-password",
  560. expect_failure=True, local_error_report=True)
  561. def test_ap_wpa2_eap_pwd_groups(dev, apdev):
  562. """WPA2-Enterprise connection using various EAP-pwd groups"""
  563. params = { "ssid": "test-wpa2-eap", "wpa": "2", "wpa_key_mgmt": "WPA-EAP",
  564. "rsn_pairwise": "CCMP", "ieee8021x": "1",
  565. "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf" }
  566. for i in [ 19, 20, 21, 25, 26 ]:
  567. params['pwd_group'] = str(i)
  568. hostapd.add_ap(apdev[0]['ifname'], params)
  569. dev[0].request("REMOVE_NETWORK all")
  570. eap_connect(dev[0], apdev[0], "PWD", "pwd user", password="secret password")
  571. def test_ap_wpa2_eap_gpsk(dev, apdev):
  572. """WPA2-Enterprise connection using EAP-GPSK"""
  573. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  574. hostapd.add_ap(apdev[0]['ifname'], params)
  575. id = eap_connect(dev[0], apdev[0], "GPSK", "gpsk user",
  576. password="abcdefghijklmnop0123456789abcdef")
  577. eap_reauth(dev[0], "GPSK")
  578. logger.info("Test forced algorithm selection")
  579. for phase1 in [ "cipher=1", "cipher=2" ]:
  580. dev[0].set_network_quoted(id, "phase1", phase1)
  581. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
  582. if ev is None:
  583. raise Exception("EAP success timed out")
  584. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
  585. if ev is None:
  586. raise Exception("Association with the AP timed out")
  587. logger.info("Test failed algorithm negotiation")
  588. dev[0].set_network_quoted(id, "phase1", "cipher=9")
  589. ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=10)
  590. if ev is None:
  591. raise Exception("EAP failure timed out")
  592. logger.info("Negative test with incorrect password")
  593. dev[0].request("REMOVE_NETWORK all")
  594. eap_connect(dev[0], apdev[0], "GPSK", "gpsk user",
  595. password="ffcdefghijklmnop0123456789abcdef",
  596. expect_failure=True)
  597. def test_ap_wpa2_eap_sake(dev, apdev):
  598. """WPA2-Enterprise connection using EAP-SAKE"""
  599. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  600. hostapd.add_ap(apdev[0]['ifname'], params)
  601. eap_connect(dev[0], apdev[0], "SAKE", "sake user",
  602. password_hex="0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
  603. eap_reauth(dev[0], "SAKE")
  604. logger.info("Negative test with incorrect password")
  605. dev[0].request("REMOVE_NETWORK all")
  606. eap_connect(dev[0], apdev[0], "SAKE", "sake user",
  607. password_hex="ff23456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  608. expect_failure=True)
  609. def test_ap_wpa2_eap_eke(dev, apdev):
  610. """WPA2-Enterprise connection using EAP-EKE"""
  611. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  612. hostapd.add_ap(apdev[0]['ifname'], params)
  613. id = eap_connect(dev[0], apdev[0], "EKE", "eke user", password="hello")
  614. eap_reauth(dev[0], "EKE")
  615. logger.info("Test forced algorithm selection")
  616. for phase1 in [ "dhgroup=5 encr=1 prf=2 mac=2",
  617. "dhgroup=4 encr=1 prf=2 mac=2",
  618. "dhgroup=3 encr=1 prf=2 mac=2",
  619. "dhgroup=3 encr=1 prf=1 mac=1" ]:
  620. dev[0].set_network_quoted(id, "phase1", phase1)
  621. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
  622. if ev is None:
  623. raise Exception("EAP success timed out")
  624. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
  625. if ev is None:
  626. raise Exception("Association with the AP timed out")
  627. logger.info("Test failed algorithm negotiation")
  628. dev[0].set_network_quoted(id, "phase1", "dhgroup=9 encr=9 prf=9 mac=9")
  629. ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=10)
  630. if ev is None:
  631. raise Exception("EAP failure timed out")
  632. logger.info("Negative test with incorrect password")
  633. dev[0].request("REMOVE_NETWORK all")
  634. eap_connect(dev[0], apdev[0], "EKE", "eke user", password="hello1",
  635. expect_failure=True)
  636. def test_ap_wpa2_eap_ikev2(dev, apdev):
  637. """WPA2-Enterprise connection using EAP-IKEv2"""
  638. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  639. hostapd.add_ap(apdev[0]['ifname'], params)
  640. eap_connect(dev[0], apdev[0], "IKEV2", "ikev2 user",
  641. password="ike password")
  642. eap_reauth(dev[0], "IKEV2")
  643. dev[0].request("REMOVE_NETWORK all")
  644. eap_connect(dev[0], apdev[0], "IKEV2", "ikev2 user",
  645. password="ike password", fragment_size="250")
  646. logger.info("Negative test with incorrect password")
  647. dev[0].request("REMOVE_NETWORK all")
  648. eap_connect(dev[0], apdev[0], "IKEV2", "ikev2 user",
  649. password="ike-password", expect_failure=True)
  650. def test_ap_wpa2_eap_pax(dev, apdev):
  651. """WPA2-Enterprise connection using EAP-PAX"""
  652. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  653. hostapd.add_ap(apdev[0]['ifname'], params)
  654. eap_connect(dev[0], apdev[0], "PAX", "pax.user@example.com",
  655. password_hex="0123456789abcdef0123456789abcdef")
  656. eap_reauth(dev[0], "PAX")
  657. logger.info("Negative test with incorrect password")
  658. dev[0].request("REMOVE_NETWORK all")
  659. eap_connect(dev[0], apdev[0], "PAX", "pax.user@example.com",
  660. password_hex="ff23456789abcdef0123456789abcdef",
  661. expect_failure=True)
  662. def test_ap_wpa2_eap_psk(dev, apdev):
  663. """WPA2-Enterprise connection using EAP-PSK"""
  664. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  665. params["wpa_key_mgmt"] = "WPA-EAP-SHA256"
  666. params["ieee80211w"] = "2"
  667. hostapd.add_ap(apdev[0]['ifname'], params)
  668. eap_connect(dev[0], apdev[0], "PSK", "psk.user@example.com",
  669. password_hex="0123456789abcdef0123456789abcdef", sha256=True)
  670. eap_reauth(dev[0], "PSK", sha256=True)
  671. logger.info("Negative test with incorrect password")
  672. dev[0].request("REMOVE_NETWORK all")
  673. eap_connect(dev[0], apdev[0], "PSK", "psk.user@example.com",
  674. password_hex="ff23456789abcdef0123456789abcdef", sha256=True,
  675. expect_failure=True)
  676. def test_ap_wpa_eap_peap_eap_mschapv2(dev, apdev):
  677. """WPA-Enterprise connection using EAP-PEAP/EAP-MSCHAPv2"""
  678. params = hostapd.wpa_eap_params(ssid="test-wpa-eap")
  679. hostapd.add_ap(apdev[0]['ifname'], params)
  680. dev[0].connect("test-wpa-eap", key_mgmt="WPA-EAP", eap="PEAP",
  681. identity="user", password="password", phase2="auth=MSCHAPV2",
  682. ca_cert="auth_serv/ca.pem", wait_connect=False,
  683. scan_freq="2412")
  684. eap_check_auth(dev[0], "PEAP", True, rsn=False)
  685. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  686. eap_reauth(dev[0], "PEAP", rsn=False)
  687. def test_ap_wpa2_eap_interactive(dev, apdev):
  688. """WPA2-Enterprise connection using interactive identity/password entry"""
  689. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  690. hostapd.add_ap(apdev[0]['ifname'], params)
  691. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  692. tests = [ ("Connection with dynamic TTLS/MSCHAPv2 password entry",
  693. "TTLS", "ttls", "DOMAIN\mschapv2 user", "auth=MSCHAPV2",
  694. None, "password"),
  695. ("Connection with dynamic TTLS/MSCHAPv2 identity and password entry",
  696. "TTLS", "ttls", None, "auth=MSCHAPV2",
  697. "DOMAIN\mschapv2 user", "password"),
  698. ("Connection with dynamic TTLS/EAP-MSCHAPv2 password entry",
  699. "TTLS", "ttls", "user", "autheap=MSCHAPV2", None, "password"),
  700. ("Connection with dynamic TTLS/EAP-MD5 password entry",
  701. "TTLS", "ttls", "user", "autheap=MD5", None, "password"),
  702. ("Connection with dynamic PEAP/EAP-MSCHAPv2 password entry",
  703. "PEAP", None, "user", "auth=MSCHAPV2", None, "password"),
  704. ("Connection with dynamic PEAP/EAP-GTC password entry",
  705. "PEAP", None, "user", "auth=GTC", None, "password") ]
  706. for [desc,eap,anon,identity,phase2,req_id,req_pw] in tests:
  707. logger.info(desc)
  708. dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap=eap,
  709. anonymous_identity=anon, identity=identity,
  710. ca_cert="auth_serv/ca.pem", phase2=phase2,
  711. wait_connect=False, scan_freq="2412")
  712. if req_id:
  713. ev = dev[0].wait_event(["CTRL-REQ-IDENTITY"])
  714. if ev is None:
  715. raise Exception("Request for identity timed out")
  716. id = ev.split(':')[0].split('-')[-1]
  717. dev[0].request("CTRL-RSP-IDENTITY-" + id + ":" + req_id)
  718. ev = dev[0].wait_event(["CTRL-REQ-PASSWORD","CTRL-REQ-OTP"])
  719. if ev is None:
  720. raise Exception("Request for password timed out")
  721. id = ev.split(':')[0].split('-')[-1]
  722. type = "OTP" if "CTRL-REQ-OTP" in ev else "PASSWORD"
  723. dev[0].request("CTRL-RSP-" + type + "-" + id + ":" + req_pw)
  724. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
  725. if ev is None:
  726. raise Exception("Connection timed out")
  727. dev[0].request("REMOVE_NETWORK all")
  728. def test_ap_wpa2_eap_vendor_test(dev, apdev):
  729. """WPA2-Enterprise connection using EAP vendor test"""
  730. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  731. hostapd.add_ap(apdev[0]['ifname'], params)
  732. eap_connect(dev[0], apdev[0], "VENDOR-TEST", "vendor-test")
  733. eap_reauth(dev[0], "VENDOR-TEST")
  734. def test_ap_wpa2_eap_fast_mschapv2_unauth_prov(dev, apdev):
  735. """WPA2-Enterprise connection using EAP-FAST/MSCHAPv2 and unauthenticated provisioning"""
  736. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  737. hostapd.add_ap(apdev[0]['ifname'], params)
  738. eap_connect(dev[0], apdev[0], "FAST", "user",
  739. anonymous_identity="FAST", password="password",
  740. ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2",
  741. phase1="fast_provisioning=1", pac_file="blob://fast_pac")
  742. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  743. eap_reauth(dev[0], "FAST")
  744. def test_ap_wpa2_eap_fast_gtc_auth_prov(dev, apdev):
  745. """WPA2-Enterprise connection using EAP-FAST/GTC and authenticated provisioning"""
  746. params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
  747. hostapd.add_ap(apdev[0]['ifname'], params)
  748. eap_connect(dev[0], apdev[0], "FAST", "user",
  749. anonymous_identity="FAST", password="password",
  750. ca_cert="auth_serv/ca.pem", phase2="auth=GTC",
  751. phase1="fast_provisioning=2", pac_file="blob://fast_pac_auth")
  752. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  753. eap_reauth(dev[0], "FAST")