test_ieee8021x.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. # IEEE 802.1X tests
  2. # Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. from remotehost import remote_compatible
  7. import binascii
  8. import hmac
  9. import logging
  10. import os
  11. import time
  12. import hostapd
  13. import hwsim_utils
  14. from utils import skip_with_fips
  15. from tshark import run_tshark
  16. logger = logging.getLogger()
  17. def test_ieee8021x_wep104(dev, apdev):
  18. """IEEE 802.1X connection using dynamic WEP104"""
  19. skip_with_fips(dev[0])
  20. params = hostapd.radius_params()
  21. params["ssid"] = "ieee8021x-wep"
  22. params["ieee8021x"] = "1"
  23. params["wep_key_len_broadcast"] = "13"
  24. params["wep_key_len_unicast"] = "13"
  25. hapd = hostapd.add_ap(apdev[0], params)
  26. dev[0].connect("ieee8021x-wep", key_mgmt="IEEE8021X", eap="PSK",
  27. identity="psk.user@example.com",
  28. password_hex="0123456789abcdef0123456789abcdef",
  29. scan_freq="2412")
  30. hwsim_utils.test_connectivity(dev[0], hapd)
  31. def test_ieee8021x_wep40(dev, apdev):
  32. """IEEE 802.1X connection using dynamic WEP40"""
  33. skip_with_fips(dev[0])
  34. params = hostapd.radius_params()
  35. params["ssid"] = "ieee8021x-wep"
  36. params["ieee8021x"] = "1"
  37. params["wep_key_len_broadcast"] = "5"
  38. params["wep_key_len_unicast"] = "5"
  39. hapd = hostapd.add_ap(apdev[0], params)
  40. dev[0].connect("ieee8021x-wep", key_mgmt="IEEE8021X", eap="PSK",
  41. identity="psk.user@example.com",
  42. password_hex="0123456789abcdef0123456789abcdef",
  43. scan_freq="2412")
  44. hwsim_utils.test_connectivity(dev[0], hapd)
  45. def test_ieee8021x_open(dev, apdev):
  46. """IEEE 802.1X connection using open network"""
  47. params = hostapd.radius_params()
  48. params["ssid"] = "ieee8021x-open"
  49. params["ieee8021x"] = "1"
  50. hapd = hostapd.add_ap(apdev[0], params)
  51. id = dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  52. eap="PSK", identity="psk.user@example.com",
  53. password_hex="0123456789abcdef0123456789abcdef",
  54. scan_freq="2412")
  55. hwsim_utils.test_connectivity(dev[0], hapd)
  56. logger.info("Test EAPOL-Logoff")
  57. dev[0].request("LOGOFF")
  58. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
  59. if ev is None:
  60. raise Exception("Did not get disconnected")
  61. if "reason=23" not in ev:
  62. raise Exception("Unexpected disconnection reason")
  63. dev[0].request("LOGON")
  64. dev[0].connect_network(id)
  65. hwsim_utils.test_connectivity(dev[0], hapd)
  66. def test_ieee8021x_static_wep40(dev, apdev):
  67. """IEEE 802.1X connection using static WEP40"""
  68. params = hostapd.radius_params()
  69. params["ssid"] = "ieee8021x-wep"
  70. params["ieee8021x"] = "1"
  71. params["wep_key0"] = '"hello"'
  72. hapd = hostapd.add_ap(apdev[0], params)
  73. dev[0].connect("ieee8021x-wep", key_mgmt="IEEE8021X", eap="PSK",
  74. identity="psk.user@example.com",
  75. password_hex="0123456789abcdef0123456789abcdef",
  76. wep_key0='"hello"', eapol_flags="0",
  77. scan_freq="2412")
  78. hwsim_utils.test_connectivity(dev[0], hapd)
  79. def test_ieee8021x_proto(dev, apdev):
  80. """IEEE 802.1X and EAPOL supplicant protocol testing"""
  81. params = hostapd.radius_params()
  82. params["ssid"] = "ieee8021x-open"
  83. params["ieee8021x"] = "1"
  84. hapd = hostapd.add_ap(apdev[0], params)
  85. bssid = apdev[0]['bssid']
  86. dev[1].request("SET ext_eapol_frame_io 1")
  87. dev[1].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  88. eap="PSK", identity="psk.user@example.com",
  89. password_hex="0123456789abcdef0123456789abcdef",
  90. scan_freq="2412", wait_connect=False)
  91. id = dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  92. eap="PSK", identity="psk.user@example.com",
  93. password_hex="0123456789abcdef0123456789abcdef",
  94. scan_freq="2412")
  95. ev = dev[1].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=5)
  96. start = dev[0].get_mib()
  97. tests = [ "11",
  98. "11223344",
  99. "020000050a93000501",
  100. "020300050a93000501",
  101. "0203002c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  102. "0203002c0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  103. "0203002c0100050000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  104. "02aa00050a93000501" ]
  105. for frame in tests:
  106. res = dev[0].request("EAPOL_RX " + bssid + " " + frame)
  107. if "OK" not in res:
  108. raise Exception("EAPOL_RX to wpa_supplicant failed")
  109. dev[1].request("EAPOL_RX " + bssid + " " + frame)
  110. stop = dev[0].get_mib()
  111. logger.info("MIB before test frames: " + str(start))
  112. logger.info("MIB after test frames: " + str(stop))
  113. vals = [ 'dot1xSuppInvalidEapolFramesRx',
  114. 'dot1xSuppEapLengthErrorFramesRx' ]
  115. for val in vals:
  116. if int(stop[val]) <= int(start[val]):
  117. raise Exception(val + " did not increase")
  118. @remote_compatible
  119. def test_ieee8021x_eapol_start(dev, apdev):
  120. """IEEE 802.1X and EAPOL-Start retransmissions"""
  121. params = hostapd.radius_params()
  122. params["ssid"] = "ieee8021x-open"
  123. params["ieee8021x"] = "1"
  124. hapd = hostapd.add_ap(apdev[0], params)
  125. bssid = apdev[0]['bssid']
  126. addr0 = dev[0].own_addr()
  127. hapd.set("ext_eapol_frame_io", "1")
  128. try:
  129. dev[0].request("SET EAPOL::startPeriod 1")
  130. dev[0].request("SET EAPOL::maxStart 1")
  131. dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  132. eap="PSK", identity="psk.user@example.com",
  133. password_hex="0123456789abcdef0123456789abcdef",
  134. scan_freq="2412", wait_connect=False)
  135. held = False
  136. for i in range(30):
  137. pae = dev[0].get_status_field('Supplicant PAE state')
  138. if pae == "HELD":
  139. mib = hapd.get_sta(addr0, info="eapol")
  140. if mib['auth_pae_state'] != 'AUTHENTICATING':
  141. raise Exception("Unexpected Auth PAE state: " + mib['auth_pae_state'])
  142. held = True
  143. break
  144. time.sleep(0.25)
  145. if not held:
  146. raise Exception("PAE state HELD not reached")
  147. dev[0].wait_disconnected()
  148. finally:
  149. dev[0].request("SET EAPOL::startPeriod 30")
  150. dev[0].request("SET EAPOL::maxStart 3")
  151. def test_ieee8021x_held(dev, apdev):
  152. """IEEE 802.1X and HELD state"""
  153. params = hostapd.radius_params()
  154. params["ssid"] = "ieee8021x-open"
  155. params["ieee8021x"] = "1"
  156. hapd = hostapd.add_ap(apdev[0], params)
  157. bssid = apdev[0]['bssid']
  158. hapd.set("ext_eapol_frame_io", "1")
  159. try:
  160. dev[0].request("SET EAPOL::startPeriod 1")
  161. dev[0].request("SET EAPOL::maxStart 0")
  162. dev[0].request("SET EAPOL::heldPeriod 1")
  163. dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  164. eap="PSK", identity="psk.user@example.com",
  165. password_hex="0123456789abcdef0123456789abcdef",
  166. scan_freq="2412", wait_connect=False)
  167. held = False
  168. for i in range(30):
  169. pae = dev[0].get_status_field('Supplicant PAE state')
  170. if pae == "HELD":
  171. held = True
  172. break
  173. time.sleep(0.25)
  174. if not held:
  175. raise Exception("PAE state HELD not reached")
  176. hapd.set("ext_eapol_frame_io", "0")
  177. for i in range(30):
  178. pae = dev[0].get_status_field('Supplicant PAE state')
  179. if pae != "HELD":
  180. held = False
  181. break
  182. time.sleep(0.25)
  183. if held:
  184. raise Exception("PAE state HELD not left")
  185. ev = dev[0].wait_event([ "CTRL-EVENT-CONNECTED",
  186. "CTRL-EVENT-DISCONNECTED" ], timeout=10)
  187. if ev is None:
  188. raise Exception("Connection timed out")
  189. if "CTRL-EVENT-DISCONNECTED" in ev:
  190. raise Exception("Unexpected disconnection")
  191. finally:
  192. dev[0].request("SET EAPOL::startPeriod 30")
  193. dev[0].request("SET EAPOL::maxStart 3")
  194. dev[0].request("SET EAPOL::heldPeriod 60")
  195. def send_eapol_key(dev, bssid, signkey, frame_start, frame_end):
  196. zero_sign = "00000000000000000000000000000000"
  197. frame = frame_start + zero_sign + frame_end
  198. hmac_obj = hmac.new(binascii.unhexlify(signkey))
  199. hmac_obj.update(binascii.unhexlify(frame))
  200. sign = hmac_obj.digest()
  201. frame = frame_start + binascii.hexlify(sign) + frame_end
  202. dev.request("EAPOL_RX " + bssid + " " + frame)
  203. def test_ieee8021x_eapol_key(dev, apdev):
  204. """IEEE 802.1X connection and EAPOL-Key protocol tests"""
  205. skip_with_fips(dev[0])
  206. params = hostapd.radius_params()
  207. params["ssid"] = "ieee8021x-wep"
  208. params["ieee8021x"] = "1"
  209. params["wep_key_len_broadcast"] = "5"
  210. params["wep_key_len_unicast"] = "5"
  211. hapd = hostapd.add_ap(apdev[0], params)
  212. bssid = apdev[0]['bssid']
  213. dev[0].connect("ieee8021x-wep", key_mgmt="IEEE8021X", eap="VENDOR-TEST",
  214. identity="vendor-test", scan_freq="2412")
  215. # Hardcoded MSK from VENDOR-TEST
  216. encrkey = "1111111111111111111111111111111111111111111111111111111111111111"
  217. signkey = "2222222222222222222222222222222222222222222222222222222222222222"
  218. # EAPOL-Key replay counter does not increase
  219. send_eapol_key(dev[0], bssid, signkey,
  220. "02030031" + "010005" + "0000000000000000" + "056c22d109f29d4d9fb9b9ccbad33283" + "02",
  221. "1c636a30a4")
  222. # EAPOL-Key too large Key Length field value
  223. send_eapol_key(dev[0], bssid, signkey,
  224. "02030031" + "010021" + "ffffffffffffffff" + "056c22d109f29d4d9fb9b9ccbad33283" + "02",
  225. "1c636a30a4")
  226. # EAPOL-Key too much key data
  227. send_eapol_key(dev[0], bssid, signkey,
  228. "0203004d" + "010005" + "ffffffffffffffff" + "056c22d109f29d4d9fb9b9ccbad33283" + "02",
  229. 33*"ff")
  230. # EAPOL-Key too little key data
  231. send_eapol_key(dev[0], bssid, signkey,
  232. "02030030" + "010005" + "ffffffffffffffff" + "056c22d109f29d4d9fb9b9ccbad33283" + "02",
  233. "1c636a30")
  234. # EAPOL-Key with no key data and too long WEP key length
  235. send_eapol_key(dev[0], bssid, signkey,
  236. "0203002c" + "010020" + "ffffffffffffffff" + "056c22d109f29d4d9fb9b9ccbad33283" + "02",
  237. "")
  238. def test_ieee8021x_reauth(dev, apdev):
  239. """IEEE 802.1X and EAPOL_REAUTH request"""
  240. params = hostapd.radius_params()
  241. params["ssid"] = "ieee8021x-open"
  242. params["ieee8021x"] = "1"
  243. hapd = hostapd.add_ap(apdev[0], params)
  244. dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  245. eap="PSK", identity="psk.user@example.com",
  246. password_hex="0123456789abcdef0123456789abcdef",
  247. scan_freq="2412")
  248. hapd.request("EAPOL_REAUTH " + dev[0].own_addr())
  249. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=5)
  250. if ev is None:
  251. raise Exception("EAP authentication did not start")
  252. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=5)
  253. if ev is None:
  254. raise Exception("EAP authentication did not succeed")
  255. time.sleep(0.1)
  256. hwsim_utils.test_connectivity(dev[0], hapd)
  257. def test_ieee8021x_reauth_wep(dev, apdev, params):
  258. """IEEE 802.1X and EAPOL_REAUTH request with WEP"""
  259. logdir = params['logdir']
  260. params = hostapd.radius_params()
  261. params["ssid"] = "ieee8021x-open"
  262. params["ieee8021x"] = "1"
  263. params["wep_key_len_broadcast"] = "13"
  264. params["wep_key_len_unicast"] = "13"
  265. hapd = hostapd.add_ap(apdev[0], params)
  266. dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X",
  267. eap="PSK", identity="psk.user@example.com",
  268. password_hex="0123456789abcdef0123456789abcdef",
  269. scan_freq="2412")
  270. hwsim_utils.test_connectivity(dev[0], hapd)
  271. hapd.request("EAPOL_REAUTH " + dev[0].own_addr())
  272. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=5)
  273. if ev is None:
  274. raise Exception("EAP authentication did not start")
  275. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=5)
  276. if ev is None:
  277. raise Exception("EAP authentication did not succeed")
  278. time.sleep(0.1)
  279. hwsim_utils.test_connectivity(dev[0], hapd)
  280. out = run_tshark(os.path.join(logdir, "hwsim0.pcapng"),
  281. "llc.type == 0x888e", ["eapol.type", "eap.code"])
  282. if out is None:
  283. raise Exception("Could not find EAPOL frames in capture")
  284. num_eapol_key = 0
  285. num_eap_req = 0
  286. num_eap_resp = 0
  287. for line in out.splitlines():
  288. vals = line.split()
  289. if vals[0] == '3':
  290. num_eapol_key += 1
  291. if vals[0] == '0' and len(vals) == 2:
  292. if vals[1] == '1':
  293. num_eap_req += 1
  294. elif vals[1] == '2':
  295. num_eap_resp += 1
  296. logger.info("num_eapol_key: %d" % num_eapol_key)
  297. logger.info("num_eap_req: %d" % num_eap_req)
  298. logger.info("num_eap_resp: %d" % num_eap_resp)
  299. if num_eapol_key < 4:
  300. raise Exception("Did not see four unencrypted EAPOL-Key frames")
  301. if num_eap_req < 6:
  302. raise Exception("Did not see six unencrypted EAP-Request frames")
  303. if num_eap_resp < 6:
  304. raise Exception("Did not see six unencrypted EAP-Response frames")
  305. def test_ieee8021x_set_conf(dev, apdev):
  306. """IEEE 802.1X and EAPOL_SET command"""
  307. params = hostapd.radius_params()
  308. params["ssid"] = "ieee8021x-open"
  309. params["ieee8021x"] = "1"
  310. hapd = hostapd.add_ap(apdev[0], params)
  311. dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  312. eap="PSK", identity="psk.user@example.com",
  313. password_hex="0123456789abcdef0123456789abcdef",
  314. scan_freq="2412")
  315. addr0 = dev[0].own_addr()
  316. tests = [ "EAPOL_SET 1",
  317. "EAPOL_SET %sfoo bar" % addr0,
  318. "EAPOL_SET %s foo" % addr0,
  319. "EAPOL_SET %s foo bar" % addr0,
  320. "EAPOL_SET %s AdminControlledDirections bar" % addr0,
  321. "EAPOL_SET %s AdminControlledPortControl bar" % addr0,
  322. "EAPOL_SET %s reAuthEnabled bar" % addr0,
  323. "EAPOL_SET %s KeyTransmissionEnabled bar" % addr0,
  324. "EAPOL_SET 11:22:33:44:55:66 AdminControlledDirections Both" ]
  325. for t in tests:
  326. if "FAIL" not in hapd.request(t):
  327. raise Exception("Invalid EAPOL_SET command accepted: " + t)
  328. tests = [ ("AdminControlledDirections", "adminControlledDirections", "In"),
  329. ("AdminControlledDirections", "adminControlledDirections",
  330. "Both"),
  331. ("quietPeriod", "quietPeriod", "13"),
  332. ("serverTimeout", "serverTimeout", "7"),
  333. ("reAuthPeriod", "reAuthPeriod", "1234"),
  334. ("reAuthEnabled", "reAuthEnabled", "FALSE"),
  335. ("reAuthEnabled", "reAuthEnabled", "TRUE"),
  336. ("KeyTransmissionEnabled", "keyTxEnabled", "TRUE"),
  337. ("KeyTransmissionEnabled", "keyTxEnabled", "FALSE"),
  338. ("AdminControlledPortControl", "portControl", "ForceAuthorized"),
  339. ("AdminControlledPortControl", "portControl",
  340. "ForceUnauthorized"),
  341. ("AdminControlledPortControl", "portControl", "Auto") ]
  342. for param,mibparam,val in tests:
  343. if "OK" not in hapd.request("EAPOL_SET %s %s %s" % (addr0, param, val)):
  344. raise Exception("Failed to set %s %s" % (param, val))
  345. mib = hapd.get_sta(addr0, info="eapol")
  346. if mib[mibparam] != val:
  347. raise Exception("Unexpected %s value: %s (expected %s)" % (param, mib[mibparam], val))
  348. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=5)
  349. if ev is None:
  350. raise Exception("EAP authentication did not succeed")
  351. time.sleep(0.1)
  352. hwsim_utils.test_connectivity(dev[0], hapd)
  353. def test_ieee8021x_auth_awhile(dev, apdev):
  354. """IEEE 802.1X and EAPOL Authenticator aWhile handling"""
  355. params = hostapd.radius_params()
  356. params["ssid"] = "ieee8021x-open"
  357. params["ieee8021x"] = "1"
  358. params['auth_server_port'] = "18129"
  359. hapd = hostapd.add_ap(apdev[0], params)
  360. bssid = apdev[0]['bssid']
  361. addr0 = dev[0].own_addr()
  362. params = {}
  363. params['ssid'] = 'as'
  364. params['beacon_int'] = '2000'
  365. params['radius_server_clients'] = 'auth_serv/radius_clients.conf'
  366. params['radius_server_auth_port'] = '18129'
  367. params['eap_server'] = '1'
  368. params['eap_user_file'] = 'auth_serv/eap_user.conf'
  369. params['ca_cert'] = 'auth_serv/ca.pem'
  370. params['server_cert'] = 'auth_serv/server.pem'
  371. params['private_key'] = 'auth_serv/server.key'
  372. hapd1 = hostapd.add_ap(apdev[1], params)
  373. dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  374. eap="PSK", identity="psk.user@example.com",
  375. password_hex="0123456789abcdef0123456789abcdef",
  376. scan_freq="2412")
  377. hapd1.disable()
  378. if "OK" not in hapd.request("EAPOL_SET %s serverTimeout 1" % addr0):
  379. raise Exception("Failed to set serverTimeout")
  380. hapd.request("EAPOL_REAUTH " + dev[0].own_addr())
  381. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"], timeout=5)
  382. for i in range(40):
  383. mib = hapd.get_sta(addr0, info="eapol")
  384. val = int(mib['aWhile'])
  385. if val > 0:
  386. break
  387. time.sleep(1)
  388. if val == 0:
  389. raise Exception("aWhile did not increase")
  390. hapd.dump_monitor()
  391. for i in range(40):
  392. mib = hapd.get_sta(addr0, info="eapol")
  393. val = int(mib['aWhile'])
  394. if val < 5:
  395. break
  396. time.sleep(1)
  397. ev = hapd.wait_event(["CTRL-EVENT-EAP-PROPOSED"], timeout=10)
  398. if ev is None:
  399. raise Exception("Authentication restart not seen")
  400. def test_ieee8021x_open_leap(dev, apdev):
  401. """IEEE 802.1X connection with LEAP included in configuration"""
  402. params = hostapd.radius_params()
  403. params["ssid"] = "ieee8021x-open"
  404. params["ieee8021x"] = "1"
  405. hapd = hostapd.add_ap(apdev[0], params)
  406. dev[1].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  407. eap="LEAP", identity="psk.user@example.com",
  408. password_hex="0123456789abcdef0123456789abcdef",
  409. scan_freq="2412", wait_connect=False)
  410. dev[0].connect("ieee8021x-open", key_mgmt="IEEE8021X", eapol_flags="0",
  411. eap="PSK LEAP", identity="psk.user@example.com",
  412. password_hex="0123456789abcdef0123456789abcdef",
  413. scan_freq="2412")
  414. ev = dev[1].wait_event(["CTRL-EVENT-AUTH-REJECT"], timeout=5)
  415. dev[1].request("DISCONNECT")
  416. def test_ieee8021x_and_wpa_enabled(dev, apdev):
  417. """IEEE 802.1X connection using dynamic WEP104 when WPA enabled"""
  418. skip_with_fips(dev[0])
  419. params = hostapd.radius_params()
  420. params["ssid"] = "ieee8021x-wep"
  421. params["ieee8021x"] = "1"
  422. params["wep_key_len_broadcast"] = "13"
  423. params["wep_key_len_unicast"] = "13"
  424. hapd = hostapd.add_ap(apdev[0], params)
  425. dev[0].connect("ieee8021x-wep", key_mgmt="IEEE8021X WPA-EAP", eap="PSK",
  426. identity="psk.user@example.com",
  427. password_hex="0123456789abcdef0123456789abcdef",
  428. scan_freq="2412")
  429. hwsim_utils.test_connectivity(dev[0], hapd)