test_dpp.py 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066
  1. # Test cases for Device Provisioning Protocol (DPP)
  2. # Copyright (c) 2017, Qualcomm Atheros, Inc.
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import logging
  7. logger = logging.getLogger()
  8. import time
  9. import hostapd
  10. import hwsim_utils
  11. from utils import HwsimSkip
  12. from wpasupplicant import WpaSupplicant
  13. def check_dpp_capab(dev):
  14. if "UNKNOWN COMMAND" in dev.request("DPP_BOOTSTRAP_GET_URI 0"):
  15. raise HwsimSkip("DPP not supported")
  16. def test_dpp_qr_code_parsing(dev, apdev):
  17. """DPP QR Code parsing"""
  18. check_dpp_capab(dev[0])
  19. id = []
  20. tests = [ "DPP:C:81/1,115/36;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADM2206avxHJaHXgLMkq/24e0rsrfMP9K1Tm8gx+ovP0I=;;",
  21. "DPP:I:SN=4774LH2b4044;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;",
  22. "DPP:I:;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;" ]
  23. for uri in tests:
  24. res = dev[0].request("DPP_QR_CODE " + uri)
  25. if "FAIL" in res:
  26. raise Exception("Failed to parse QR Code")
  27. id.append(int(res))
  28. uri2 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id[-1])
  29. if uri != uri2:
  30. raise Exception("Returned URI does not match")
  31. tests = [ "foo",
  32. "DPP:",
  33. "DPP:;;",
  34. "DPP:C:1/2;M:;K;;",
  35. "DPP:I:;M:01020304050;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;" ]
  36. for t in tests:
  37. res = dev[0].request("DPP_QR_CODE " + t)
  38. if "FAIL" not in res:
  39. raise Exception("Accepted invalid QR Code: " + t)
  40. logger.info("ID: " + str(id))
  41. if id[0] == id[1] or id[0] == id[2] or id[1] == id[2]:
  42. raise Exception("Duplicate ID returned")
  43. if "FAIL" not in dev[0].request("DPP_BOOTSTRAP_REMOVE 12345678"):
  44. raise Exception("DPP_BOOTSTRAP_REMOVE accepted unexpectedly")
  45. if "OK" not in dev[0].request("DPP_BOOTSTRAP_REMOVE %d" % id[1]):
  46. raise Exception("DPP_BOOTSTRAP_REMOVE failed")
  47. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode")
  48. if "FAIL" in res:
  49. raise Exception("Failed to generate bootstrapping info")
  50. uri = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % int(res))
  51. logger.info("Generated URI: " + uri)
  52. res = dev[0].request("DPP_QR_CODE " + uri)
  53. if "FAIL" in res:
  54. raise Exception("Failed to parse self-generated QR Code URI")
  55. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1,115/36 mac=010203040506 info=foo")
  56. if "FAIL" in res:
  57. raise Exception("Failed to generate bootstrapping info")
  58. uri = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % int(res))
  59. logger.info("Generated URI: " + uri)
  60. res = dev[0].request("DPP_QR_CODE " + uri)
  61. if "FAIL" in res:
  62. raise Exception("Failed to parse self-generated QR Code URI")
  63. def test_dpp_qr_code_auth_broadcast(dev, apdev):
  64. """DPP QR Code and authentication exchange (broadcast)"""
  65. check_dpp_capab(dev[0])
  66. check_dpp_capab(dev[1])
  67. logger.info("dev0 displays QR Code")
  68. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1")
  69. if "FAIL" in res:
  70. raise Exception("Failed to generate bootstrapping info")
  71. id0 = int(res)
  72. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  73. logger.info("dev1 scans QR Code")
  74. res = dev[1].request("DPP_QR_CODE " + uri0)
  75. if "FAIL" in res:
  76. raise Exception("Failed to parse QR Code URI")
  77. id1 = int(res)
  78. logger.info("dev1 initiates DPP Authentication")
  79. if "OK" not in dev[0].request("DPP_LISTEN 2412"):
  80. raise Exception("Failed to start listen operation")
  81. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d" % id1):
  82. raise Exception("Failed to initiate DPP Authentication")
  83. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  84. if ev is None:
  85. raise Exception("DPP authentication did not succeed (Responder)")
  86. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  87. if ev is None:
  88. raise Exception("DPP authentication did not succeed (Initiator)")
  89. dev[0].request("DPP_STOP_LISTEN")
  90. def test_dpp_qr_code_auth_unicast(dev, apdev):
  91. """DPP QR Code and authentication exchange (unicast)"""
  92. run_dpp_qr_code_auth_unicast(dev, apdev, None)
  93. def test_dpp_qr_code_auth_unicast_ap_enrollee(dev, apdev):
  94. """DPP QR Code and authentication exchange (AP enrollee)"""
  95. run_dpp_qr_code_auth_unicast(dev, apdev, None, netrole="ap")
  96. def test_dpp_qr_code_curve_prime256v1(dev, apdev):
  97. """DPP QR Code and curve prime256v1"""
  98. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1")
  99. def test_dpp_qr_code_curve_secp384r1(dev, apdev):
  100. """DPP QR Code and curve secp384r1"""
  101. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1")
  102. def test_dpp_qr_code_curve_secp521r1(dev, apdev):
  103. """DPP QR Code and curve secp521r1"""
  104. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1")
  105. def test_dpp_qr_code_curve_brainpoolP256r1(dev, apdev):
  106. """DPP QR Code and curve brainpoolP256r1"""
  107. run_dpp_qr_code_auth_unicast(dev, apdev, "brainpoolP256r1")
  108. def test_dpp_qr_code_curve_brainpoolP384r1(dev, apdev):
  109. """DPP QR Code and curve brainpoolP384r1"""
  110. run_dpp_qr_code_auth_unicast(dev, apdev, "brainpoolP384r1")
  111. def test_dpp_qr_code_curve_brainpoolP512r1(dev, apdev):
  112. """DPP QR Code and curve brainpoolP512r1"""
  113. run_dpp_qr_code_auth_unicast(dev, apdev, "brainpoolP512r1")
  114. def test_dpp_qr_code_set_key(dev, apdev):
  115. """DPP QR Code and fixed bootstrapping key"""
  116. run_dpp_qr_code_auth_unicast(dev, apdev, None, key="30770201010420e5143ac74682cc6869a830e8f5301a5fa569130ac329b1d7dd6f2a7495dbcbe1a00a06082a8648ce3d030107a144034200045e13e167c33dbc7d85541e5509600aa8139bbb3e39e25898992c5d01be92039ee2850f17e71506ded0d6b25677441eae249f8e225c68dd15a6354dca54006383")
  117. def run_dpp_qr_code_auth_unicast(dev, apdev, curve, netrole=None, key=None,
  118. require_conf_success=False, init_extra=None,
  119. require_conf_failure=False,
  120. configurator=False, conf_curve=None):
  121. check_dpp_capab(dev[0])
  122. check_dpp_capab(dev[1])
  123. if configurator:
  124. logger.info("Create configurator on dev1")
  125. cmd = "DPP_CONFIGURATOR_ADD"
  126. if conf_curve:
  127. cmd += " curve=" + conf_curve
  128. res = dev[1].request(cmd);
  129. if "FAIL" in res:
  130. raise Exception("Failed to add configurator")
  131. conf_id = int(res)
  132. logger.info("dev0 displays QR Code")
  133. addr = dev[0].own_addr().replace(':', '')
  134. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  135. if curve:
  136. cmd += " curve=" + curve
  137. if key:
  138. cmd += " key=" + key
  139. res = dev[0].request(cmd)
  140. if "FAIL" in res:
  141. raise Exception("Failed to generate bootstrapping info")
  142. id0 = int(res)
  143. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  144. logger.info("dev1 scans QR Code")
  145. res = dev[1].request("DPP_QR_CODE " + uri0)
  146. if "FAIL" in res:
  147. raise Exception("Failed to parse QR Code URI")
  148. id1 = int(res)
  149. logger.info("dev1 initiates DPP Authentication")
  150. cmd = "DPP_LISTEN 2412"
  151. if netrole:
  152. cmd += " netrole=" + netrole
  153. if "OK" not in dev[0].request(cmd):
  154. raise Exception("Failed to start listen operation")
  155. cmd = "DPP_AUTH_INIT peer=%d" % id1
  156. if init_extra:
  157. cmd += " " + init_extra
  158. if configurator:
  159. cmd += " configurator=%d" % conf_id
  160. if "OK" not in dev[1].request(cmd):
  161. raise Exception("Failed to initiate DPP Authentication")
  162. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  163. if ev is None:
  164. raise Exception("DPP authentication did not succeed (Responder)")
  165. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  166. if ev is None:
  167. raise Exception("DPP authentication did not succeed (Initiator)")
  168. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=5)
  169. if ev is None:
  170. raise Exception("DPP configuration not completed (Configurator)")
  171. ev = dev[0].wait_event(["DPP-CONF-RECEIVED", "DPP-CONF-FAILED"], timeout=5)
  172. if ev is None:
  173. raise Exception("DPP configuration not completed (Enrollee)")
  174. if require_conf_success:
  175. if "DPP-CONF-FAILED" in ev:
  176. raise Exception("DPP configuration failed")
  177. if require_conf_failure:
  178. if "DPP-CONF-SUCCESS" in ev:
  179. raise Exception("DPP configuration succeeded unexpectedly")
  180. dev[0].request("DPP_STOP_LISTEN")
  181. dev[0].dump_monitor()
  182. dev[1].dump_monitor()
  183. def test_dpp_qr_code_auth_mutual(dev, apdev):
  184. """DPP QR Code and authentication exchange (mutual)"""
  185. check_dpp_capab(dev[0])
  186. check_dpp_capab(dev[1])
  187. logger.info("dev0 displays QR Code")
  188. addr = dev[0].own_addr().replace(':', '')
  189. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  190. if "FAIL" in res:
  191. raise Exception("Failed to generate bootstrapping info")
  192. id0 = int(res)
  193. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  194. logger.info("dev1 scans QR Code")
  195. res = dev[1].request("DPP_QR_CODE " + uri0)
  196. if "FAIL" in res:
  197. raise Exception("Failed to parse QR Code URI")
  198. id1 = int(res)
  199. logger.info("dev1 displays QR Code")
  200. addr = dev[1].own_addr().replace(':', '')
  201. res = dev[1].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  202. if "FAIL" in res:
  203. raise Exception("Failed to generate bootstrapping info")
  204. id1b = int(res)
  205. uri1b = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1b)
  206. logger.info("dev0 scans QR Code")
  207. res = dev[0].request("DPP_QR_CODE " + uri1b)
  208. if "FAIL" in res:
  209. raise Exception("Failed to parse QR Code URI")
  210. id0b = int(res)
  211. logger.info("dev1 initiates DPP Authentication")
  212. if "OK" not in dev[0].request("DPP_LISTEN 2412"):
  213. raise Exception("Failed to start listen operation")
  214. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d own=%d" % (id1, id1b)):
  215. raise Exception("Failed to initiate DPP Authentication")
  216. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  217. if ev is None:
  218. raise Exception("DPP authentication did not succeed (Responder)")
  219. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  220. if ev is None:
  221. raise Exception("DPP authentication did not succeed (Initiator)")
  222. dev[0].request("DPP_STOP_LISTEN")
  223. def test_dpp_qr_code_auth_mutual2(dev, apdev):
  224. """DPP QR Code and authentication exchange (mutual2)"""
  225. check_dpp_capab(dev[0])
  226. check_dpp_capab(dev[1])
  227. logger.info("dev0 displays QR Code")
  228. addr = dev[0].own_addr().replace(':', '')
  229. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  230. if "FAIL" in res:
  231. raise Exception("Failed to generate bootstrapping info")
  232. id0 = int(res)
  233. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  234. logger.info("dev1 scans QR Code")
  235. res = dev[1].request("DPP_QR_CODE " + uri0)
  236. if "FAIL" in res:
  237. raise Exception("Failed to parse QR Code URI")
  238. id1 = int(res)
  239. logger.info("dev1 displays QR Code")
  240. addr = dev[1].own_addr().replace(':', '')
  241. res = dev[1].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  242. if "FAIL" in res:
  243. raise Exception("Failed to generate bootstrapping info")
  244. id1b = int(res)
  245. uri1b = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1b)
  246. logger.info("dev1 initiates DPP Authentication")
  247. if "OK" not in dev[0].request("DPP_LISTEN 2412 qr=mutual"):
  248. raise Exception("Failed to start listen operation")
  249. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d own=%d" % (id1, id1b)):
  250. raise Exception("Failed to initiate DPP Authentication")
  251. ev = dev[1].wait_event(["DPP-RESPONSE-PENDING"], timeout=5)
  252. if ev is None:
  253. raise Exception("Pending response not reported")
  254. ev = dev[0].wait_event(["DPP-SCAN-PEER-QR-CODE"], timeout=5)
  255. if ev is None:
  256. raise Exception("QR Code scan for mutual authentication not requested")
  257. logger.info("dev0 scans QR Code")
  258. res = dev[0].request("DPP_QR_CODE " + uri1b)
  259. if "FAIL" in res:
  260. raise Exception("Failed to parse QR Code URI")
  261. id0b = int(res)
  262. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  263. if ev is None:
  264. raise Exception("DPP authentication did not succeed (Responder)")
  265. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  266. if ev is None:
  267. raise Exception("DPP authentication did not succeed (Initiator)")
  268. dev[0].request("DPP_STOP_LISTEN")
  269. def test_dpp_qr_code_auth_mutual_not_used(dev, apdev):
  270. """DPP QR Code and authentication exchange (mutual not used)"""
  271. check_dpp_capab(dev[0])
  272. check_dpp_capab(dev[1])
  273. logger.info("dev0 displays QR Code")
  274. addr = dev[0].own_addr().replace(':', '')
  275. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  276. if "FAIL" in res:
  277. raise Exception("Failed to generate bootstrapping info")
  278. id0 = int(res)
  279. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  280. logger.info("dev1 scans QR Code")
  281. res = dev[1].request("DPP_QR_CODE " + uri0)
  282. if "FAIL" in res:
  283. raise Exception("Failed to parse QR Code URI")
  284. id1 = int(res)
  285. logger.info("dev1 displays QR Code")
  286. addr = dev[1].own_addr().replace(':', '')
  287. res = dev[1].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  288. if "FAIL" in res:
  289. raise Exception("Failed to generate bootstrapping info")
  290. id1b = int(res)
  291. uri1b = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1b)
  292. logger.info("dev0 does not scan QR Code")
  293. logger.info("dev1 initiates DPP Authentication")
  294. if "OK" not in dev[0].request("DPP_LISTEN 2412"):
  295. raise Exception("Failed to start listen operation")
  296. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d own=%d" % (id1, id1b)):
  297. raise Exception("Failed to initiate DPP Authentication")
  298. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  299. if ev is None:
  300. raise Exception("DPP authentication did not succeed (Responder)")
  301. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  302. if ev is None:
  303. raise Exception("DPP authentication did not succeed (Initiator)")
  304. dev[0].request("DPP_STOP_LISTEN")
  305. def test_dpp_qr_code_auth_mutual_curve_mismatch(dev, apdev):
  306. """DPP QR Code and authentication exchange (mutual/mismatch)"""
  307. check_dpp_capab(dev[0])
  308. check_dpp_capab(dev[1])
  309. logger.info("dev0 displays QR Code")
  310. addr = dev[0].own_addr().replace(':', '')
  311. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  312. if "FAIL" in res:
  313. raise Exception("Failed to generate bootstrapping info")
  314. id0 = int(res)
  315. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  316. logger.info("dev1 scans QR Code")
  317. res = dev[1].request("DPP_QR_CODE " + uri0)
  318. if "FAIL" in res:
  319. raise Exception("Failed to parse QR Code URI")
  320. id1 = int(res)
  321. logger.info("dev1 displays QR Code")
  322. addr = dev[1].own_addr().replace(':', '')
  323. res = dev[1].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr + " curve=secp384r1")
  324. if "FAIL" in res:
  325. raise Exception("Failed to generate bootstrapping info")
  326. id1b = int(res)
  327. uri1b = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1b)
  328. logger.info("dev0 scans QR Code")
  329. res = dev[0].request("DPP_QR_CODE " + uri1b)
  330. if "FAIL" in res:
  331. raise Exception("Failed to parse QR Code URI")
  332. id0b = int(res)
  333. res = dev[1].request("DPP_AUTH_INIT peer=%d own=%d" % (id1, id1b))
  334. if "FAIL" not in res:
  335. raise Exception("DPP_AUTH_INIT accepted unexpectedly")
  336. def test_dpp_qr_code_listen_continue(dev, apdev):
  337. """DPP QR Code and listen operation needing continuation"""
  338. check_dpp_capab(dev[0])
  339. check_dpp_capab(dev[1])
  340. logger.info("dev0 displays QR Code")
  341. addr = dev[0].own_addr().replace(':', '')
  342. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  343. if "FAIL" in res:
  344. raise Exception("Failed to generate bootstrapping info")
  345. id0 = int(res)
  346. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  347. logger.info("dev1 scans QR Code")
  348. res = dev[1].request("DPP_QR_CODE " + uri0)
  349. if "FAIL" in res:
  350. raise Exception("Failed to parse QR Code URI")
  351. id1 = int(res)
  352. if "OK" not in dev[0].request("DPP_LISTEN 2412"):
  353. raise Exception("Failed to start listen operation")
  354. logger.info("Wait for listen to expire and get restarted")
  355. time.sleep(5.5)
  356. logger.info("dev1 initiates DPP Authentication")
  357. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d" % id1):
  358. raise Exception("Failed to initiate DPP Authentication")
  359. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  360. if ev is None:
  361. raise Exception("DPP authentication did not succeed (Responder)")
  362. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  363. if ev is None:
  364. raise Exception("DPP authentication did not succeed (Initiator)")
  365. dev[0].request("DPP_STOP_LISTEN")
  366. def test_dpp_qr_code_auth_initiator_enrollee(dev, apdev):
  367. """DPP QR Code and authentication exchange (Initiator in Enrollee role)"""
  368. check_dpp_capab(dev[0])
  369. check_dpp_capab(dev[1])
  370. dev[0].request("SET gas_address3 1")
  371. dev[1].request("SET gas_address3 1")
  372. logger.info("dev0 displays QR Code")
  373. addr = dev[0].own_addr().replace(':', '')
  374. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  375. if "FAIL" in res:
  376. raise Exception("Failed to generate bootstrapping info")
  377. id0 = int(res)
  378. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  379. logger.info("dev1 scans QR Code")
  380. res = dev[1].request("DPP_QR_CODE " + uri0)
  381. if "FAIL" in res:
  382. raise Exception("Failed to parse QR Code URI")
  383. id1 = int(res)
  384. logger.info("dev1 initiates DPP Authentication")
  385. if "OK" not in dev[0].request("DPP_LISTEN 2412"):
  386. raise Exception("Failed to start listen operation")
  387. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=enrollee" % id1):
  388. raise Exception("Failed to initiate DPP Authentication")
  389. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  390. if ev is None:
  391. raise Exception("DPP authentication did not succeed (Responder)")
  392. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  393. if ev is None:
  394. raise Exception("DPP authentication did not succeed (Initiator)")
  395. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  396. if ev is None:
  397. raise Exception("DPP configuration did not succeed (Configurator)")
  398. ev = dev[1].wait_event(["DPP-CONF-FAILED"], timeout=5)
  399. if ev is None:
  400. raise Exception("DPP configuration did not succeed (Enrollee)")
  401. dev[0].request("DPP_STOP_LISTEN")
  402. def test_dpp_qr_code_auth_incompatible_roles(dev, apdev):
  403. """DPP QR Code and authentication exchange (incompatible roles)"""
  404. check_dpp_capab(dev[0])
  405. check_dpp_capab(dev[1])
  406. logger.info("dev0 displays QR Code")
  407. addr = dev[0].own_addr().replace(':', '')
  408. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  409. if "FAIL" in res:
  410. raise Exception("Failed to generate bootstrapping info")
  411. id0 = int(res)
  412. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  413. logger.info("dev1 scans QR Code")
  414. res = dev[1].request("DPP_QR_CODE " + uri0)
  415. if "FAIL" in res:
  416. raise Exception("Failed to parse QR Code URI")
  417. id1 = int(res)
  418. logger.info("dev1 initiates DPP Authentication")
  419. if "OK" not in dev[0].request("DPP_LISTEN 2412 role=enrollee"):
  420. raise Exception("Failed to start listen operation")
  421. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=enrollee" % id1):
  422. raise Exception("Failed to initiate DPP Authentication")
  423. ev = dev[1].wait_event(["DPP-NOT-COMPATIBLE"], timeout=5)
  424. if ev is None:
  425. raise Exception("DPP-NOT-COMPATIBLE event on initiator timed out")
  426. ev = dev[0].wait_event(["DPP-NOT-COMPATIBLE"], timeout=1)
  427. if ev is None:
  428. raise Exception("DPP-NOT-COMPATIBLE event on responder timed out")
  429. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=configurator" % id1):
  430. raise Exception("Failed to initiate DPP Authentication")
  431. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  432. if ev is None:
  433. raise Exception("DPP authentication did not succeed (Responder)")
  434. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  435. if ev is None:
  436. raise Exception("DPP authentication did not succeed (Initiator)")
  437. dev[0].request("DPP_STOP_LISTEN")
  438. def test_dpp_config_legacy(dev, apdev):
  439. """DPP Config Object for legacy network using passphrase"""
  440. check_dpp_capab(dev[1])
  441. conf = '{"wi-fi_tech":"infra", "discovery":{"ssid":"test"},"cred":{"akm":"psk","pass":"secret passphrase"}}'
  442. dev[1].set("dpp_config_obj_override", conf)
  443. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  444. require_conf_success=True)
  445. def test_dpp_config_legacy_psk_hex(dev, apdev):
  446. """DPP Config Object for legacy network using PSK"""
  447. check_dpp_capab(dev[1])
  448. conf = '{"wi-fi_tech":"infra", "discovery":{"ssid":"test"},"cred":{"akm":"psk","psk_hex":"' + 32*"12" + '"}}'
  449. dev[1].set("dpp_config_obj_override", conf)
  450. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  451. require_conf_success=True)
  452. def test_dpp_config_fragmentation(dev, apdev):
  453. """DPP Config Object for legacy network requiring fragmentation"""
  454. check_dpp_capab(dev[1])
  455. conf = '{"wi-fi_tech":"infra", "discovery":{"ssid":"test"},"cred":{"akm":"psk","pass":"secret passphrase"}}' + 3000*' '
  456. dev[1].set("dpp_config_obj_override", conf)
  457. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  458. require_conf_success=True)
  459. def test_dpp_config_legacy_gen(dev, apdev):
  460. """Generate DPP Config Object for legacy network"""
  461. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  462. init_extra="conf=sta-psk pass=%s" % "passphrase".encode("hex"),
  463. require_conf_success=True)
  464. def test_dpp_config_dpp_gen_prime256v1(dev, apdev):
  465. """Generate DPP Config Object for DPP network (P-256)"""
  466. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  467. init_extra="conf=sta-dpp",
  468. require_conf_success=True,
  469. configurator=True)
  470. def test_dpp_config_dpp_gen_secp384r1(dev, apdev):
  471. """Generate DPP Config Object for DPP network (P-384)"""
  472. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  473. init_extra="conf=sta-dpp",
  474. require_conf_success=True,
  475. configurator=True)
  476. def test_dpp_config_dpp_gen_secp521r1(dev, apdev):
  477. """Generate DPP Config Object for DPP network (P-521)"""
  478. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  479. init_extra="conf=sta-dpp",
  480. require_conf_success=True,
  481. configurator=True)
  482. def test_dpp_config_dpp_gen_prime256v1_prime256v1(dev, apdev):
  483. """Generate DPP Config Object for DPP network (P-256 + P-256)"""
  484. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  485. init_extra="conf=sta-dpp",
  486. require_conf_success=True,
  487. configurator=True,
  488. conf_curve="prime256v1")
  489. def test_dpp_config_dpp_gen_prime256v1_secp384r1(dev, apdev):
  490. """Generate DPP Config Object for DPP network (P-256 + P-384)"""
  491. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  492. init_extra="conf=sta-dpp",
  493. require_conf_success=True,
  494. configurator=True,
  495. conf_curve="secp384r1")
  496. def test_dpp_config_dpp_gen_prime256v1_secp521r1(dev, apdev):
  497. """Generate DPP Config Object for DPP network (P-256 + P-521)"""
  498. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  499. init_extra="conf=sta-dpp",
  500. require_conf_success=True,
  501. configurator=True,
  502. conf_curve="secp521r1")
  503. def test_dpp_config_dpp_gen_secp384r1_prime256v1(dev, apdev):
  504. """Generate DPP Config Object for DPP network (P-384 + P-256)"""
  505. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  506. init_extra="conf=sta-dpp",
  507. require_conf_success=True,
  508. configurator=True,
  509. conf_curve="prime256v1")
  510. def test_dpp_config_dpp_gen_secp384r1_secp384r1(dev, apdev):
  511. """Generate DPP Config Object for DPP network (P-384 + P-384)"""
  512. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  513. init_extra="conf=sta-dpp",
  514. require_conf_success=True,
  515. configurator=True,
  516. conf_curve="secp384r1")
  517. def test_dpp_config_dpp_gen_secp384r1_secp521r1(dev, apdev):
  518. """Generate DPP Config Object for DPP network (P-384 + P-521)"""
  519. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  520. init_extra="conf=sta-dpp",
  521. require_conf_success=True,
  522. configurator=True,
  523. conf_curve="secp521r1")
  524. def test_dpp_config_dpp_gen_secp521r1_prime256v1(dev, apdev):
  525. """Generate DPP Config Object for DPP network (P-521 + P-256)"""
  526. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  527. init_extra="conf=sta-dpp",
  528. require_conf_success=True,
  529. configurator=True,
  530. conf_curve="prime256v1")
  531. def test_dpp_config_dpp_gen_secp521r1_secp384r1(dev, apdev):
  532. """Generate DPP Config Object for DPP network (P-521 + P-384)"""
  533. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  534. init_extra="conf=sta-dpp",
  535. require_conf_success=True,
  536. configurator=True,
  537. conf_curve="secp384r1")
  538. def test_dpp_config_dpp_gen_secp521r1_secp521r1(dev, apdev):
  539. """Generate DPP Config Object for DPP network (P-521 + P-521)"""
  540. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  541. init_extra="conf=sta-dpp",
  542. require_conf_success=True,
  543. configurator=True,
  544. conf_curve="secp521r1")
  545. def test_dpp_config_dpp_gen_expiry(dev, apdev):
  546. """Generate DPP Config Object for DPP network with expiry value"""
  547. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  548. init_extra="conf=sta-dpp expiry=%d" % (time.time() + 1000),
  549. require_conf_success=True,
  550. configurator=True)
  551. def test_dpp_config_dpp_gen_expired_key(dev, apdev):
  552. """Generate DPP Config Object for DPP network with expiry value"""
  553. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  554. init_extra="conf=sta-dpp expiry=%d" % (time.time() - 10),
  555. require_conf_failure=True,
  556. configurator=True)
  557. def test_dpp_config_dpp_override_prime256v1(dev, apdev):
  558. """DPP Config Object override (P-256)"""
  559. check_dpp_capab(dev[0])
  560. check_dpp_capab(dev[1])
  561. conf = '{"wi-fi_tech":"infra","discovery":{"ssid":"test"},"cred":{"akm":"dpp","signedConnector":"eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJUbkdLaklsTlphYXRyRUFZcmJiamlCNjdyamtMX0FHVldYTzZxOWhESktVIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiYVRGNEpFR0lQS1NaMFh2OXpkQ01qbS10bjVYcE1zWUlWWjl3eVNBejFnSSIsInkiOiJRR2NIV0FfNnJiVTlYRFhBenRvWC1NNVEzc3VUbk1hcUVoVUx0bjdTU1h3In19._sm6YswxMf6hJLVTyYoU1uYUeY2VVkUNjrzjSiEhY42StD_RWowStEE-9CRsdCvLmsTptZ72_g40vTFwdId20A","csign":{"kty":"EC","crv":"P-256","x":"W4-Y5N1Pkos3UWb9A5qme0KUYRtY3CVUpekx_MapZ9s","y":"Et-M4NSF4NGjvh2VCh4B1sJ9eSCZ4RNzP2DBdP137VE","kid":"TnGKjIlNZaatrEAYrbbjiB67rjkL_AGVWXO6q9hDJKU"}}}'
  562. dev[0].set("dpp_ignore_netaccesskey_mismatch", "1")
  563. dev[1].set("dpp_config_obj_override", conf)
  564. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  565. require_conf_success=True)
  566. def test_dpp_config_dpp_override_secp384r1(dev, apdev):
  567. """DPP Config Object override (P-384)"""
  568. check_dpp_capab(dev[0])
  569. check_dpp_capab(dev[1])
  570. conf = '{"wi-fi_tech":"infra","discovery":{"ssid":"test"},"cred":{"akm":"dpp","signedConnector":"eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJabi1iMndjbjRLM2pGQklkYmhGZkpVTHJTXzdESS0yMWxFQi02R3gxNjl3IiwiYWxnIjoiRVMzODQifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC0zODQiLCJ4IjoickdrSGg1UUZsOUtfWjdqYUZkVVhmbThoY1RTRjM1b25Xb1NIRXVsbVNzWW9oX1RXZGpoRjhiVGdiS0ZRN2tBViIsInkiOiJBbU1QVDA5VmFENWpGdzMwTUFKQlp2VkZXeGNlVVlKLXR5blQ0bVJ5N0xOZWxhZ0dEWHpfOExaRlpOU2FaNUdLIn19.Yn_F7m-bbOQ5PlaYQJ9-1qsuqYQ6V-rAv8nWw1COKiCYwwbt3WFBJ8DljY0dPrlg5CHJC4saXwkytpI-CpELW1yUdzYb4Lrun07d20Eo_g10ICyOl5sqQCAUElKMe_Xr","csign":{"kty":"EC","crv":"P-384","x":"dmTyXXiPV2Y8a01fujL-jo08gvzyby23XmzOtzjAiujKQZZgPJsbhfEKrZDlc6ey","y":"H5Z0av5c7bqInxYb2_OOJdNiMhVf3zlcULR0516ZZitOY4U31KhL4wl4KGV7g2XW","kid":"Zn-b2wcn4K3jFBIdbhFfJULrS_7DI-21lEB-6Gx169w"}}}'
  571. dev[0].set("dpp_ignore_netaccesskey_mismatch", "1")
  572. dev[1].set("dpp_config_obj_override", conf)
  573. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  574. require_conf_success=True)
  575. def test_dpp_config_dpp_override_secp521r1(dev, apdev):
  576. """DPP Config Object override (P-521)"""
  577. check_dpp_capab(dev[0])
  578. check_dpp_capab(dev[1])
  579. conf = '{"wi-fi_tech":"infra","discovery":{"ssid":"test"},"cred":{"akm":"dpp","signedConnector":"eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJMZkhKY3hnV2ZKcG1uS2IwenZRT0F2VDB2b0ZKc0JjZnBmYzgxY3Y5ZXFnIiwiYWxnIjoiRVM1MTIifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC01MjEiLCJ4IjoiQVJlUFBrMFNISkRRR2NWbnlmM3lfbTlaQllHNjFJeElIbDN1NkdwRHVhMkU1WVd4TE1BSUtMMnZuUGtlSGFVRXljRmZaZlpYZ2JlNkViUUxMVkRVUm1VUSIsInkiOiJBWUtaYlNwUkFFNjJVYm9YZ2c1ZWRBVENzbEpzTlpwcm9RR1dUcW9Md04weXkzQkVoT3ZRZmZrOWhaR2lKZ295TzFobXFRRVRrS0pXb2tIYTBCQUpLSGZtIn19.ACEZLyPk13cM_OFScpLoCElQ2t1sxq5z2d_W_3_QslTQQe5SFiH_o8ycL4632YLAH4RV0gZcMKKRMtZdHgBYHjkzASDqgY-_aYN2SBmpfl8hw0YdDlUJWX3DJf-ofqNAlTbnGmhpSg69cEAhFn41Xgvx2MdwYcPVncxxESVOtWl5zNLK","csign":{"kty":"EC","crv":"P-521","x":"ADiOI_YJOAipEXHB-SpGl4KqokX8m8h3BVYCc8dgiwssZ061-nIIY3O1SIO6Re4Jjfy53RPgzDG6jitOgOGLtzZs","y":"AZKggKaQi0ExutSpJAU3-lqDV03sBQLA9C7KabfWoAn8qD6Vk4jU0WAJdt-wBBTF9o1nVuiqS2OxMVYrxN4lOz79","kid":"LfHJcxgWfJpmnKb0zvQOAvT0voFJsBcfpfc81cv9eqg"}}}'
  580. dev[0].set("dpp_ignore_netaccesskey_mismatch", "1")
  581. dev[1].set("dpp_config_obj_override", conf)
  582. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  583. require_conf_success=True)
  584. def test_dpp_config_override_objects(dev, apdev):
  585. """Generate DPP Config Object and override objects)"""
  586. check_dpp_capab(dev[1])
  587. discovery = '{\n"ssid":"mywifi"\n}'
  588. groups = '[\n {"groupId":"home","netRole":"sta"},\n {"groupId":"cottage","netRole":"sta"}\n]'
  589. dev[1].set("dpp_discovery_override", discovery)
  590. dev[1].set("dpp_groups_override", groups)
  591. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  592. init_extra="conf=sta-dpp",
  593. require_conf_success=True,
  594. configurator=True)
  595. def test_dpp_gas_timeout(dev, apdev):
  596. """DPP and GAS server timeout for a query"""
  597. check_dpp_capab(dev[0])
  598. check_dpp_capab(dev[1])
  599. logger.info("dev0 displays QR Code")
  600. addr = dev[0].own_addr().replace(':', '')
  601. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  602. res = dev[0].request(cmd)
  603. if "FAIL" in res:
  604. raise Exception("Failed to generate bootstrapping info")
  605. id0 = int(res)
  606. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  607. logger.info("dev1 scans QR Code")
  608. res = dev[1].request("DPP_QR_CODE " + uri0)
  609. if "FAIL" in res:
  610. raise Exception("Failed to parse QR Code URI")
  611. id1 = int(res)
  612. logger.info("dev1 initiates DPP Authentication")
  613. dev[0].set("ext_mgmt_frame_handling", "1")
  614. cmd = "DPP_LISTEN 2412"
  615. if "OK" not in dev[0].request(cmd):
  616. raise Exception("Failed to start listen operation")
  617. # Force GAS fragmentation
  618. conf = '{"wi-fi_tech":"infra", "discovery":{"ssid":"test"},"cred":{"akm":"psk","pass":"secret passphrase"}}' + 3000*' '
  619. dev[1].set("dpp_config_obj_override", conf)
  620. cmd = "DPP_AUTH_INIT peer=%d" % id1
  621. if "OK" not in dev[1].request(cmd):
  622. raise Exception("Failed to initiate DPP Authentication")
  623. # DPP Authentication Request
  624. msg = dev[0].mgmt_rx()
  625. if "OK" not in dev[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(msg['freq'], msg['datarate'], msg['ssi_signal'], msg['frame'].encode('hex'))):
  626. raise Exception("MGMT_RX_PROCESS failed")
  627. # DPP Authentication Confirmation
  628. msg = dev[0].mgmt_rx()
  629. if "OK" not in dev[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(msg['freq'], msg['datarate'], msg['ssi_signal'], msg['frame'].encode('hex'))):
  630. raise Exception("MGMT_RX_PROCESS failed")
  631. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  632. if ev is None:
  633. raise Exception("DPP authentication did not succeed (Responder)")
  634. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  635. if ev is None:
  636. raise Exception("DPP authentication did not succeed (Initiator)")
  637. # DPP Configuration Response (GAS Initial Response frame)
  638. msg = dev[0].mgmt_rx()
  639. if "OK" not in dev[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(msg['freq'], msg['datarate'], msg['ssi_signal'], msg['frame'].encode('hex'))):
  640. raise Exception("MGMT_RX_PROCESS failed")
  641. # GAS Comeback Response frame
  642. msg = dev[0].mgmt_rx()
  643. # Do not continue to force timeout on GAS server
  644. ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=10)
  645. if ev is None:
  646. raise Exception("GAS result not reported (Enrollee)")
  647. if "result=TIMEOUT" not in ev:
  648. raise Exception("Unexpected GAS result (Enrollee): " + ev)
  649. dev[0].set("ext_mgmt_frame_handling", "0")
  650. ev = dev[1].wait_event(["DPP-CONF-FAILED"], timeout=15)
  651. if ev is None:
  652. raise Exception("DPP configuration failure not reported (Configurator)")
  653. ev = dev[0].wait_event(["DPP-CONF-FAILED"], timeout=1)
  654. if ev is None:
  655. raise Exception("DPP configuration failure not reported (Enrollee)")
  656. def test_dpp_akm_sha256(dev, apdev):
  657. """DPP AKM (SHA256)"""
  658. run_dpp_akm(dev, apdev, 32)
  659. def test_dpp_akm_sha384(dev, apdev):
  660. """DPP AKM (SHA384)"""
  661. run_dpp_akm(dev, apdev, 48)
  662. def test_dpp_akm_sha512(dev, apdev):
  663. """DPP AKM (SHA512)"""
  664. run_dpp_akm(dev, apdev, 64)
  665. def run_dpp_akm(dev, apdev, pmk_len):
  666. check_dpp_capab(dev[0])
  667. check_dpp_capab(dev[1])
  668. params = { "ssid": "dpp",
  669. "wpa": "2",
  670. "wpa_key_mgmt": "DPP",
  671. "rsn_pairwise": "CCMP" }
  672. try:
  673. hapd = hostapd.add_ap(apdev[0], params)
  674. except:
  675. raise HwsimSkip("DPP not supported")
  676. id = dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412",
  677. wait_connect=False)
  678. ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=2)
  679. if not ev:
  680. raise Exception("Network mismatch not reported")
  681. dev[0].request("DISCONNECT")
  682. dev[0].dump_monitor()
  683. bssid = hapd.own_addr()
  684. pmkid = 16*'11'
  685. akmp = 2**23
  686. pmk = pmk_len*'22'
  687. cmd = "PMKSA_ADD %d %s %s %s 30240 43200 %d 0" % (id, bssid, pmkid, pmk, akmp)
  688. if "OK" not in dev[0].request(cmd):
  689. raise Exception("PMKSA_ADD failed (wpa_supplicant)")
  690. dev[0].select_network(id, freq="2412")
  691. ev = dev[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"], timeout=2)
  692. dev[0].request("DISCONNECT")
  693. dev[0].dump_monitor()
  694. if not ev:
  695. raise Exception("Association attempt was not rejected")
  696. if "status_code=53" not in ev:
  697. raise Exception("Unexpected status code: " + ev)
  698. addr = dev[0].own_addr()
  699. cmd = "PMKSA_ADD %s %s %s 0 %d" % (addr, pmkid, pmk, akmp)
  700. if "OK" not in hapd.request(cmd):
  701. raise Exception("PMKSA_ADD failed (hostapd)")
  702. dev[0].select_network(id, freq="2412")
  703. dev[0].wait_connected()
  704. val = dev[0].get_status_field("key_mgmt")
  705. if val != "DPP":
  706. raise Exception("Unexpected key_mgmt: " + val)
  707. def test_dpp_network_introduction(dev, apdev):
  708. """DPP network introduction"""
  709. check_dpp_capab(dev[0])
  710. check_dpp_capab(dev[1])
  711. csign = "3059301306072a8648ce3d020106082a8648ce3d03010703420004d02e5bd81a120762b5f0f2994777f5d40297238a6c294fd575cdf35fabec44c050a6421c401d98d659fd2ed13c961cc8287944dd3202f516977800d3ab2f39ee"
  712. ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIwOHF4TlNYRzRWemdCV3BjVUdNSmc1czNvbElOVFJsRVQ1aERpNkRKY3ZjIiwieSI6IlVhaGFYQXpKRVpRQk1YaHRUQnlZZVlrOWtJYjk5UDA3UV9NcW9TVVZTVEkifX0.a5_nfMVr7Qe1SW0ZL3u6oQRm5NUCYUSfixDAJOUFN3XUfECBZ6E8fm8xjeSfdOytgRidTz0CTlIRjzPQo82dmQ"
  713. ap_netaccesskey = "30770201010420f6531d17f29dfab655b7c9e923478d5a345164c489aadd44a3519c3e9dcc792da00a06082a8648ce3d030107a14403420004d3cab13525c6e15ce0056a5c506309839b37a2520d4d19444f98438ba0c972f751a85a5c0cc911940131786d4c1c9879893d9086fdf4fd3b43f32aa125154932"
  714. sta_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiZWMzR3NqQ3lQMzVBUUZOQUJJdEltQnN4WXVyMGJZX1dES1lfSE9zUGdjNCIsInkiOiJTRS1HVllkdWVnTFhLMU1TQXZNMEx2QWdLREpTNWoyQVhCbE9PMTdUSTRBIn19.PDK9zsGlK-e1pEOmNxVeJfCS8pNeay6ckIS1TXCQsR64AR-9wFPCNVjqOxWvVKltehyMFqVAtOcv0IrjtMJFqQ"
  715. sta_netaccesskey = "30770201010420bc33380c26fd2168b69cd8242ed1df07ba89aa4813f8d4e8523de6ca3f8dd28ba00a06082a8648ce3d030107a1440342000479cdc6b230b23f7e40405340048b48981b3162eaf46d8fd60ca63f1ceb0f81ce484f8655876e7a02d72b531202f3342ef020283252e63d805c194e3b5ed32380"
  716. params = { "ssid": "dpp",
  717. "wpa": "2",
  718. "wpa_key_mgmt": "DPP",
  719. "rsn_pairwise": "CCMP",
  720. "dpp_connector": ap_connector,
  721. "dpp_csign": csign,
  722. "dpp_netaccesskey": ap_netaccesskey }
  723. try:
  724. hapd = hostapd.add_ap(apdev[0], params)
  725. except:
  726. raise HwsimSkip("DPP not supported")
  727. id = dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412",
  728. dpp_csign=csign,
  729. dpp_connector=sta_connector,
  730. dpp_netaccesskey=sta_netaccesskey)
  731. val = dev[0].get_status_field("key_mgmt")
  732. if val != "DPP":
  733. raise Exception("Unexpected key_mgmt: " + val)
  734. def test_dpp_ap_config(dev, apdev):
  735. """DPP and AP configuration"""
  736. run_dpp_ap_config(dev, apdev)
  737. def test_dpp_ap_config_p256_p256(dev, apdev):
  738. """DPP and AP configuration (P-256 + P-256)"""
  739. run_dpp_ap_config(dev, apdev, curve="P-256", conf_curve="P-256")
  740. def test_dpp_ap_config_p256_p384(dev, apdev):
  741. """DPP and AP configuration (P-256 + P-384)"""
  742. run_dpp_ap_config(dev, apdev, curve="P-256", conf_curve="P-384")
  743. def test_dpp_ap_config_p256_p521(dev, apdev):
  744. """DPP and AP configuration (P-256 + P-521)"""
  745. run_dpp_ap_config(dev, apdev, curve="P-256", conf_curve="P-521")
  746. def test_dpp_ap_config_p384_p256(dev, apdev):
  747. """DPP and AP configuration (P-384 + P-256)"""
  748. run_dpp_ap_config(dev, apdev, curve="P-384", conf_curve="P-256")
  749. def test_dpp_ap_config_p384_p384(dev, apdev):
  750. """DPP and AP configuration (P-384 + P-384)"""
  751. run_dpp_ap_config(dev, apdev, curve="P-384", conf_curve="P-384")
  752. def test_dpp_ap_config_p384_p521(dev, apdev):
  753. """DPP and AP configuration (P-384 + P-521)"""
  754. run_dpp_ap_config(dev, apdev, curve="P-384", conf_curve="P-521")
  755. def test_dpp_ap_config_p521_p256(dev, apdev):
  756. """DPP and AP configuration (P-521 + P-256)"""
  757. run_dpp_ap_config(dev, apdev, curve="P-521", conf_curve="P-256")
  758. def test_dpp_ap_config_p521_p384(dev, apdev):
  759. """DPP and AP configuration (P-521 + P-384)"""
  760. run_dpp_ap_config(dev, apdev, curve="P-521", conf_curve="P-384")
  761. def test_dpp_ap_config_p521_p521(dev, apdev):
  762. """DPP and AP configuration (P-521 + P-521)"""
  763. run_dpp_ap_config(dev, apdev, curve="P-521", conf_curve="P-521")
  764. def update_hapd_config(hapd):
  765. ev = hapd.wait_event(["DPP-CONFOBJ-SSID"], timeout=1)
  766. if ev is None:
  767. raise Exception("SSID not reported (AP)")
  768. ssid = ev.split(' ')[1]
  769. ev = hapd.wait_event(["DPP-CONNECTOR"], timeout=1)
  770. if ev is None:
  771. raise Exception("Connector not reported (AP)")
  772. connector = ev.split(' ')[1]
  773. ev = hapd.wait_event(["DPP-C-SIGN-KEY"], timeout=1)
  774. if ev is None:
  775. raise Exception("C-sign-key not reported (AP)")
  776. p = ev.split(' ')
  777. csign = p[1]
  778. ev = hapd.wait_event(["DPP-NET-ACCESS-KEY"], timeout=1)
  779. if ev is None:
  780. raise Exception("netAccessKey not reported (AP)")
  781. p = ev.split(' ')
  782. net_access_key = p[1]
  783. net_access_key_expiry = p[2] if len(p) > 2 else None
  784. logger.info("Update AP configuration to use key_mgmt=DPP")
  785. hapd.disable()
  786. hapd.set("ssid", ssid)
  787. hapd.set("wpa", "2")
  788. hapd.set("wpa_key_mgmt", "DPP")
  789. hapd.set("rsn_pairwise", "CCMP")
  790. hapd.set("dpp_connector", connector)
  791. hapd.set("dpp_csign", csign)
  792. hapd.set("dpp_netaccesskey", net_access_key)
  793. if net_access_key_expiry:
  794. hapd.set("dpp_netaccesskey_expiry", net_access_key_expiry)
  795. hapd.enable()
  796. def run_dpp_ap_config(dev, apdev, curve=None, conf_curve=None):
  797. check_dpp_capab(dev[0])
  798. check_dpp_capab(dev[1])
  799. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" })
  800. check_dpp_capab(hapd)
  801. addr = hapd.own_addr().replace(':', '')
  802. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  803. if curve:
  804. cmd += " curve=" + curve
  805. res = hapd.request(cmd)
  806. if "FAIL" in res:
  807. raise Exception("Failed to generate bootstrapping info")
  808. id_h = int(res)
  809. uri = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id_h)
  810. cmd = "DPP_CONFIGURATOR_ADD"
  811. if conf_curve:
  812. cmd += " curve=" + conf_curve
  813. res = dev[0].request(cmd);
  814. if "FAIL" in res:
  815. raise Exception("Failed to add configurator")
  816. conf_id = int(res)
  817. res = dev[0].request("DPP_QR_CODE " + uri)
  818. if "FAIL" in res:
  819. raise Exception("Failed to parse QR Code URI")
  820. id = int(res)
  821. cmd = "DPP_AUTH_INIT peer=%d conf=ap-dpp configurator=%d" % (id, conf_id)
  822. if "OK" not in dev[0].request(cmd):
  823. raise Exception("Failed to initiate DPP Authentication")
  824. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  825. if ev is None:
  826. raise Exception("DPP authentication did not succeed (Responder)")
  827. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  828. if ev is None:
  829. raise Exception("DPP authentication did not succeed (Initiator)")
  830. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  831. if ev is None:
  832. raise Exception("DPP configuration not completed (Configurator)")
  833. ev = hapd.wait_event(["DPP-CONF-RECEIVED", "DPP-CONF-FAILED"], timeout=5)
  834. if ev is None:
  835. raise Exception("DPP configuration not completed (Enrollee)")
  836. if "DPP-CONF-FAILED" in ev:
  837. raise Exception("DPP configuration failed")
  838. update_hapd_config(hapd)
  839. addr = dev[1].own_addr().replace(':', '')
  840. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  841. if curve:
  842. cmd += " curve=" + curve
  843. res = dev[1].request(cmd)
  844. if "FAIL" in res:
  845. raise Exception("Failed to generate bootstrapping info")
  846. id1 = int(res)
  847. uri1 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1)
  848. res = dev[0].request("DPP_QR_CODE " + uri1)
  849. if "FAIL" in res:
  850. raise Exception("Failed to parse QR Code URI")
  851. id0b = int(res)
  852. cmd = "DPP_LISTEN 2412"
  853. if "OK" not in dev[1].request(cmd):
  854. raise Exception("Failed to start listen operation")
  855. cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id0b, conf_id)
  856. if "OK" not in dev[0].request(cmd):
  857. raise Exception("Failed to initiate DPP Authentication")
  858. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  859. if ev is None:
  860. raise Exception("DPP authentication did not succeed (Responder)")
  861. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  862. if ev is None:
  863. raise Exception("DPP authentication did not succeed (Initiator)")
  864. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  865. if ev is None:
  866. raise Exception("DPP configuration not completed (Configurator)")
  867. ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  868. if ev is None:
  869. raise Exception("DPP configuration not completed (Enrollee)")
  870. dev[1].request("DPP_STOP_LISTEN")
  871. ev = dev[1].wait_event(["DPP-CONFOBJ-SSID"], timeout=1)
  872. if ev is None:
  873. raise Exception("SSID not reported")
  874. ssid = ev.split(' ')[1]
  875. ev = dev[1].wait_event(["DPP-CONNECTOR"], timeout=1)
  876. if ev is None:
  877. raise Exception("Connector not reported")
  878. connector = ev.split(' ')[1]
  879. ev = dev[1].wait_event(["DPP-C-SIGN-KEY"], timeout=1)
  880. if ev is None:
  881. raise Exception("C-sign-key not reported")
  882. p = ev.split(' ')
  883. csign = p[1]
  884. ev = dev[1].wait_event(["DPP-NET-ACCESS-KEY"], timeout=1)
  885. if ev is None:
  886. raise Exception("netAccessKey not reported")
  887. p = ev.split(' ')
  888. net_access_key = p[1]
  889. net_access_key_expiry = p[2] if len(p) > 2 else None
  890. dev[1].dump_monitor()
  891. id = dev[1].connect(ssid, key_mgmt="DPP", scan_freq="2412",
  892. only_add_network=True)
  893. dev[1].set_network_quoted(id, "dpp_connector", connector)
  894. dev[1].set_network(id, "dpp_csign", csign)
  895. dev[1].set_network(id, "dpp_netaccesskey", net_access_key)
  896. if net_access_key_expiry:
  897. dev[1].set_network(id, "dpp_netaccess_expiry", net_access_key_expiry)
  898. logger.info("Check data connection")
  899. dev[1].select_network(id, freq="2412")
  900. dev[1].wait_connected()
  901. def test_dpp_auto_connect_1(dev, apdev):
  902. """DPP and auto connect (1)"""
  903. try:
  904. run_dpp_auto_connect(dev, apdev, 1)
  905. finally:
  906. dev[0].set("dpp_config_processing", "0")
  907. def test_dpp_auto_connect_2(dev, apdev):
  908. """DPP and auto connect (2)"""
  909. try:
  910. run_dpp_auto_connect(dev, apdev, 2)
  911. finally:
  912. dev[0].set("dpp_config_processing", "0")
  913. def test_dpp_auto_connect_2_connect_cmd(dev, apdev):
  914. """DPP and auto connect (2) using connect_cmd"""
  915. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  916. wpas.interface_add("wlan5", drv_params="force_connect_cmd=1")
  917. dev_new = [ wpas, dev[1] ]
  918. try:
  919. run_dpp_auto_connect(dev_new, apdev, 2)
  920. finally:
  921. wpas.set("dpp_config_processing", "0")
  922. def run_dpp_auto_connect(dev, apdev, processing):
  923. check_dpp_capab(dev[0])
  924. check_dpp_capab(dev[1])
  925. csign = "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
  926. csign_pub = "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
  927. ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg"
  928. ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b"
  929. params = { "ssid": "test",
  930. "wpa": "2",
  931. "wpa_key_mgmt": "DPP",
  932. "rsn_pairwise": "CCMP",
  933. "dpp_connector": ap_connector,
  934. "dpp_csign": csign_pub,
  935. "dpp_netaccesskey": ap_netaccesskey }
  936. try:
  937. hapd = hostapd.add_ap(apdev[0], params)
  938. except:
  939. raise HwsimSkip("DPP not supported")
  940. cmd = "DPP_CONFIGURATOR_ADD key=" + csign
  941. res = dev[1].request(cmd)
  942. if "FAIL" in res:
  943. raise Exception("DPP_CONFIGURATOR_ADD failed")
  944. conf_id = int(res)
  945. dev[0].set("dpp_config_processing", str(processing))
  946. addr = dev[0].own_addr().replace(':', '')
  947. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  948. res = dev[0].request(cmd)
  949. if "FAIL" in res:
  950. raise Exception("Failed to generate bootstrapping info")
  951. id0 = int(res)
  952. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  953. res = dev[1].request("DPP_QR_CODE " + uri0)
  954. if "FAIL" in res:
  955. raise Exception("Failed to parse QR Code URI")
  956. id1 = int(res)
  957. cmd = "DPP_LISTEN 2412"
  958. if "OK" not in dev[0].request(cmd):
  959. raise Exception("Failed to start listen operation")
  960. cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id1, conf_id)
  961. if "OK" not in dev[1].request(cmd):
  962. raise Exception("Failed to initiate DPP Authentication")
  963. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=10)
  964. if ev is None:
  965. raise Exception("DPP configuration not completed (Configurator)")
  966. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=2)
  967. if ev is None:
  968. raise Exception("DPP configuration not completed (Enrollee)")
  969. ev = dev[0].wait_event(["DPP-NETWORK-ID"], timeout=1)
  970. if ev is None:
  971. raise Exception("DPP network profile not generated")
  972. id = ev.split(' ')[1]
  973. if processing == 1:
  974. dev[0].select_network(id, freq=2412)
  975. dev[0].wait_connected()
  976. hwsim_utils.test_connectivity(dev[0], hapd)
  977. def test_dpp_auto_connect_legacy(dev, apdev):
  978. """DPP and auto connect (legacy)"""
  979. try:
  980. run_dpp_auto_connect_legacy(dev, apdev)
  981. finally:
  982. dev[0].set("dpp_config_processing", "0")
  983. def run_dpp_auto_connect_legacy(dev, apdev):
  984. check_dpp_capab(dev[0])
  985. check_dpp_capab(dev[1])
  986. params = hostapd.wpa2_params(ssid="dpp-legacy",
  987. passphrase="secret passphrase")
  988. hapd = hostapd.add_ap(apdev[0], params)
  989. dev[0].set("dpp_config_processing", "2")
  990. addr = dev[0].own_addr().replace(':', '')
  991. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  992. res = dev[0].request(cmd)
  993. if "FAIL" in res:
  994. raise Exception("Failed to generate bootstrapping info")
  995. id0 = int(res)
  996. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  997. res = dev[1].request("DPP_QR_CODE " + uri0)
  998. if "FAIL" in res:
  999. raise Exception("Failed to parse QR Code URI")
  1000. id1 = int(res)
  1001. cmd = "DPP_LISTEN 2412"
  1002. if "OK" not in dev[0].request(cmd):
  1003. raise Exception("Failed to start listen operation")
  1004. cmd = "DPP_AUTH_INIT peer=%d conf=sta-psk ssid=%s pass=%s" % (id1, "dpp-legacy".encode("hex"), "secret passphrase".encode("hex"))
  1005. if "OK" not in dev[1].request(cmd):
  1006. raise Exception("Failed to initiate DPP Authentication")
  1007. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=10)
  1008. if ev is None:
  1009. raise Exception("DPP configuration not completed (Configurator)")
  1010. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=2)
  1011. if ev is None:
  1012. raise Exception("DPP configuration not completed (Enrollee)")
  1013. ev = dev[0].wait_event(["DPP-NETWORK-ID"], timeout=1)
  1014. if ev is None:
  1015. raise Exception("DPP network profile not generated")
  1016. id = ev.split(' ')[1]
  1017. dev[0].wait_connected()
  1018. def test_dpp_qr_code_auth_responder_configurator(dev, apdev):
  1019. """DPP QR Code and responder as the configurator"""
  1020. check_dpp_capab(dev[0])
  1021. check_dpp_capab(dev[1])
  1022. cmd = "DPP_CONFIGURATOR_ADD"
  1023. res = dev[0].request(cmd);
  1024. if "FAIL" in res:
  1025. raise Exception("Failed to add configurator")
  1026. conf_id = int(res)
  1027. addr = dev[0].own_addr().replace(':', '')
  1028. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1029. res = dev[0].request(cmd)
  1030. if "FAIL" in res:
  1031. raise Exception("Failed to generate bootstrapping info")
  1032. id0 = int(res)
  1033. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1034. res = dev[1].request("DPP_QR_CODE " + uri0)
  1035. if "FAIL" in res:
  1036. raise Exception("Failed to parse QR Code URI")
  1037. id1 = int(res)
  1038. dev[0].set("dpp_configurator_params", " conf=sta-dpp configurator=%d" % conf_id);
  1039. cmd = "DPP_LISTEN 2412 role=configurator"
  1040. if "OK" not in dev[0].request(cmd):
  1041. raise Exception("Failed to start listen operation")
  1042. cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % id1
  1043. if "OK" not in dev[1].request(cmd):
  1044. raise Exception("Failed to initiate DPP Authentication")
  1045. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1046. if ev is None:
  1047. raise Exception("DPP authentication did not succeed (Responder)")
  1048. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1049. if ev is None:
  1050. raise Exception("DPP authentication did not succeed (Initiator)")
  1051. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1052. if ev is None:
  1053. raise Exception("DPP configuration not completed (Configurator)")
  1054. ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1055. if ev is None:
  1056. raise Exception("DPP configuration not completed (Enrollee)")
  1057. dev[0].request("DPP_STOP_LISTEN")
  1058. dev[0].dump_monitor()
  1059. dev[1].dump_monitor()
  1060. def test_dpp_qr_code_hostapd_init(dev, apdev):
  1061. """DPP QR Code and hostapd as initiator"""
  1062. check_dpp_capab(dev[0])
  1063. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1064. "channel": "6" })
  1065. check_dpp_capab(hapd)
  1066. cmd = "DPP_CONFIGURATOR_ADD"
  1067. res = dev[0].request(cmd);
  1068. if "FAIL" in res:
  1069. raise Exception("Failed to add configurator")
  1070. conf_id = int(res)
  1071. addr = dev[0].own_addr().replace(':', '')
  1072. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
  1073. res = dev[0].request(cmd)
  1074. if "FAIL" in res:
  1075. raise Exception("Failed to generate bootstrapping info")
  1076. id0 = int(res)
  1077. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1078. dev[0].set("dpp_configurator_params",
  1079. " conf=ap-dpp configurator=%d" % conf_id);
  1080. cmd = "DPP_LISTEN 2437 role=configurator"
  1081. if "OK" not in dev[0].request(cmd):
  1082. raise Exception("Failed to start listen operation")
  1083. res = hapd.request("DPP_QR_CODE " + uri0)
  1084. if "FAIL" in res:
  1085. raise Exception("Failed to parse QR Code URI")
  1086. id1 = int(res)
  1087. cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % id1
  1088. if "OK" not in hapd.request(cmd):
  1089. raise Exception("Failed to initiate DPP Authentication")
  1090. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1091. if ev is None:
  1092. raise Exception("DPP authentication did not succeed (Responder)")
  1093. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1094. if ev is None:
  1095. raise Exception("DPP authentication did not succeed (Initiator)")
  1096. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1097. if ev is None:
  1098. raise Exception("DPP configuration not completed (Configurator)")
  1099. ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1100. if ev is None:
  1101. raise Exception("DPP configuration not completed (Enrollee)")
  1102. dev[0].request("DPP_STOP_LISTEN")
  1103. dev[0].dump_monitor()
  1104. def test_dpp_pkex(dev, apdev):
  1105. """DPP and PKEX"""
  1106. run_dpp_pkex(dev, apdev)
  1107. def test_dpp_pkex_p256(dev, apdev):
  1108. """DPP and PKEX (P-256)"""
  1109. run_dpp_pkex(dev, apdev, "P-256")
  1110. def test_dpp_pkex_p384(dev, apdev):
  1111. """DPP and PKEX (P-384)"""
  1112. run_dpp_pkex(dev, apdev, "P-384")
  1113. def test_dpp_pkex_p521(dev, apdev):
  1114. """DPP and PKEX (P-521)"""
  1115. run_dpp_pkex(dev, apdev, "P-521")
  1116. def test_dpp_pkex_bp256(dev, apdev):
  1117. """DPP and PKEX (BP-256)"""
  1118. run_dpp_pkex(dev, apdev, "brainpoolP256r1")
  1119. def test_dpp_pkex_bp384(dev, apdev):
  1120. """DPP and PKEX (BP-384)"""
  1121. run_dpp_pkex(dev, apdev, "brainpoolP384r1")
  1122. def test_dpp_pkex_bp512(dev, apdev):
  1123. """DPP and PKEX (BP-512)"""
  1124. run_dpp_pkex(dev, apdev, "brainpoolP512r1")
  1125. def test_dpp_pkex_config(dev, apdev):
  1126. """DPP and PKEX with initiator as the configurator"""
  1127. check_dpp_capab(dev[1])
  1128. cmd = "DPP_CONFIGURATOR_ADD"
  1129. res = dev[1].request(cmd);
  1130. if "FAIL" in res:
  1131. raise Exception("Failed to add configurator")
  1132. conf_id = int(res)
  1133. run_dpp_pkex(dev, apdev,
  1134. init_extra="conf=sta-dpp configurator=%d" % (conf_id),
  1135. check_config=True)
  1136. def run_dpp_pkex(dev, apdev, curve=None, init_extra="", check_config=False):
  1137. check_dpp_capab(dev[0])
  1138. check_dpp_capab(dev[1])
  1139. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1140. if curve:
  1141. cmd += " curve=" + curve
  1142. res = dev[0].request(cmd)
  1143. if "FAIL" in res:
  1144. raise Exception("Failed to generate bootstrapping info")
  1145. id0 = int(res)
  1146. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1147. if curve:
  1148. cmd += " curve=" + curve
  1149. res = dev[1].request(cmd)
  1150. if "FAIL" in res:
  1151. raise Exception("Failed to generate bootstrapping info")
  1152. id1 = int(res)
  1153. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1154. res = dev[0].request(cmd)
  1155. if "FAIL" in res:
  1156. raise Exception("Failed to set PKEX data (responder)")
  1157. cmd = "DPP_LISTEN 2437"
  1158. if "OK" not in dev[0].request(cmd):
  1159. raise Exception("Failed to start listen operation")
  1160. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 %s code=secret" % (id1, init_extra)
  1161. res = dev[1].request(cmd)
  1162. if "FAIL" in res:
  1163. raise Exception("Failed to set PKEX data (initiator)")
  1164. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1165. if ev is None:
  1166. raise Exception("DPP authentication did not succeed (Initiator)")
  1167. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1168. if ev is None:
  1169. raise Exception("DPP authentication did not succeed (Responder)")
  1170. if check_config:
  1171. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=5)
  1172. if ev is None:
  1173. raise Exception("DPP configuration not completed (Configurator)")
  1174. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1175. if ev is None:
  1176. raise Exception("DPP configuration not completed (Enrollee)")
  1177. def test_dpp_pkex_config2(dev, apdev):
  1178. """DPP and PKEX with responder as the configurator"""
  1179. check_dpp_capab(dev[0])
  1180. cmd = "DPP_CONFIGURATOR_ADD"
  1181. res = dev[0].request(cmd);
  1182. if "FAIL" in res:
  1183. raise Exception("Failed to add configurator")
  1184. conf_id = int(res)
  1185. dev[0].set("dpp_configurator_params",
  1186. " conf=sta-dpp configurator=%d" % conf_id);
  1187. run_dpp_pkex2(dev, apdev)
  1188. def run_dpp_pkex2(dev, apdev, curve=None, init_extra=""):
  1189. check_dpp_capab(dev[0])
  1190. check_dpp_capab(dev[1])
  1191. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1192. if curve:
  1193. cmd += " curve=" + curve
  1194. res = dev[0].request(cmd)
  1195. if "FAIL" in res:
  1196. raise Exception("Failed to generate bootstrapping info")
  1197. id0 = int(res)
  1198. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1199. if curve:
  1200. cmd += " curve=" + curve
  1201. res = dev[1].request(cmd)
  1202. if "FAIL" in res:
  1203. raise Exception("Failed to generate bootstrapping info")
  1204. id1 = int(res)
  1205. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1206. res = dev[0].request(cmd)
  1207. if "FAIL" in res:
  1208. raise Exception("Failed to set PKEX data (responder)")
  1209. cmd = "DPP_LISTEN 2437 role=configurator"
  1210. if "OK" not in dev[0].request(cmd):
  1211. raise Exception("Failed to start listen operation")
  1212. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 role=enrollee %s code=secret" % (id1, init_extra)
  1213. res = dev[1].request(cmd)
  1214. if "FAIL" in res:
  1215. raise Exception("Failed to set PKEX data (initiator)")
  1216. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1217. if ev is None:
  1218. raise Exception("DPP authentication did not succeed (Initiator)")
  1219. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1220. if ev is None:
  1221. raise Exception("DPP authentication did not succeed (Responder)")
  1222. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1223. if ev is None:
  1224. raise Exception("DPP configuration not completed (Configurator)")
  1225. ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1226. if ev is None:
  1227. raise Exception("DPP configuration not completed (Enrollee)")
  1228. def test_dpp_pkex_hostapd_responder(dev, apdev):
  1229. """DPP PKEX with hostapd as responder"""
  1230. check_dpp_capab(dev[0])
  1231. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1232. "channel": "6" })
  1233. check_dpp_capab(hapd)
  1234. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1235. res = hapd.request(cmd)
  1236. if "FAIL" in res:
  1237. raise Exception("Failed to generate bootstrapping info (hostapd)")
  1238. id_h = int(res)
  1239. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id_h)
  1240. res = hapd.request(cmd)
  1241. if "FAIL" in res:
  1242. raise Exception("Failed to set PKEX data (responder/hostapd)")
  1243. cmd = "DPP_CONFIGURATOR_ADD"
  1244. res = dev[0].request(cmd);
  1245. if "FAIL" in res:
  1246. raise Exception("Failed to add configurator")
  1247. conf_id = int(res)
  1248. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1249. res = dev[0].request(cmd)
  1250. if "FAIL" in res:
  1251. raise Exception("Failed to generate bootstrapping info (wpa_supplicant)")
  1252. id0 = int(res)
  1253. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 conf=ap-dpp configurator=%d code=secret" % (id0, conf_id)
  1254. res = dev[0].request(cmd)
  1255. if "FAIL" in res:
  1256. raise Exception("Failed to set PKEX data (initiator/wpa_supplicant)")
  1257. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1258. if ev is None:
  1259. raise Exception("DPP authentication did not succeed (Initiator)")
  1260. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1261. if ev is None:
  1262. raise Exception("DPP authentication did not succeed (Responder)")
  1263. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1264. if ev is None:
  1265. raise Exception("DPP configuration not completed (Configurator)")
  1266. ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1267. if ev is None:
  1268. raise Exception("DPP configuration not completed (Enrollee)")
  1269. dev[0].request("DPP_STOP_LISTEN")
  1270. dev[0].dump_monitor()
  1271. def test_dpp_pkex_hostapd_initiator(dev, apdev):
  1272. """DPP PKEX with hostapd as initiator"""
  1273. check_dpp_capab(dev[0])
  1274. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1275. "channel": "6" })
  1276. check_dpp_capab(hapd)
  1277. cmd = "DPP_CONFIGURATOR_ADD"
  1278. res = dev[0].request(cmd);
  1279. if "FAIL" in res:
  1280. raise Exception("Failed to add configurator")
  1281. conf_id = int(res)
  1282. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1283. res = dev[0].request(cmd)
  1284. if "FAIL" in res:
  1285. raise Exception("Failed to generate bootstrapping info (wpa_supplicant)")
  1286. id0 = int(res)
  1287. dev[0].set("dpp_configurator_params",
  1288. " conf=ap-dpp configurator=%d" % conf_id);
  1289. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1290. res = dev[0].request(cmd)
  1291. if "FAIL" in res:
  1292. raise Exception("Failed to set PKEX data (responder/wpa_supplicant)")
  1293. cmd = "DPP_LISTEN 2437 role=configurator"
  1294. if "OK" not in dev[0].request(cmd):
  1295. raise Exception("Failed to start listen operation")
  1296. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1297. res = hapd.request(cmd)
  1298. if "FAIL" in res:
  1299. raise Exception("Failed to generate bootstrapping info (hostapd)")
  1300. id_h = int(res)
  1301. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 role=enrollee code=secret" % (id_h)
  1302. res = hapd.request(cmd)
  1303. if "FAIL" in res:
  1304. raise Exception("Failed to set PKEX data (initiator/hostapd)")
  1305. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1306. if ev is None:
  1307. raise Exception("DPP authentication did not succeed (Initiator)")
  1308. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1309. if ev is None:
  1310. raise Exception("DPP authentication did not succeed (Responder)")
  1311. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1312. if ev is None:
  1313. raise Exception("DPP configuration not completed (Configurator)")
  1314. ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1315. if ev is None:
  1316. raise Exception("DPP configuration not completed (Enrollee)")
  1317. dev[0].request("DPP_STOP_LISTEN")
  1318. dev[0].dump_monitor()
  1319. def test_dpp_hostapd_configurator(dev, apdev):
  1320. """DPP with hostapd as configurator/initiator"""
  1321. check_dpp_capab(dev[0])
  1322. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1323. "channel": "1" })
  1324. check_dpp_capab(hapd)
  1325. cmd = "DPP_CONFIGURATOR_ADD"
  1326. res = hapd.request(cmd);
  1327. if "FAIL" in res:
  1328. raise Exception("Failed to add configurator")
  1329. conf_id = int(res)
  1330. addr = dev[0].own_addr().replace(':', '')
  1331. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1332. res = dev[0].request(cmd)
  1333. if "FAIL" in res:
  1334. raise Exception("Failed to generate bootstrapping info")
  1335. id0 = int(res)
  1336. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1337. res = hapd.request("DPP_QR_CODE " + uri0)
  1338. if "FAIL" in res:
  1339. raise Exception("Failed to parse QR Code URI")
  1340. id1 = int(res)
  1341. res = hapd.request("DPP_BOOTSTRAP_INFO %d" % id0)
  1342. if "FAIL" in res:
  1343. raise Exception("DPP_BOOTSTRAP_INFO failed")
  1344. if "type=QRCODE" not in res:
  1345. raise Exception("DPP_BOOTSTRAP_INFO did not report correct type")
  1346. if "mac_addr=" + dev[0].own_addr() not in res:
  1347. raise Exception("DPP_BOOTSTRAP_INFO did not report correct mac_addr")
  1348. cmd = "DPP_LISTEN 2412"
  1349. if "OK" not in dev[0].request(cmd):
  1350. raise Exception("Failed to start listen operation")
  1351. cmd = "DPP_AUTH_INIT peer=%d configurator=%d conf=sta-dpp" % (id1, conf_id)
  1352. if "OK" not in hapd.request(cmd):
  1353. raise Exception("Failed to initiate DPP Authentication")
  1354. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1355. if ev is None:
  1356. raise Exception("DPP authentication did not succeed (Responder)")
  1357. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1358. if ev is None:
  1359. raise Exception("DPP authentication did not succeed (Initiator)")
  1360. ev = hapd.wait_event(["DPP-CONF-SENT"], timeout=5)
  1361. if ev is None:
  1362. raise Exception("DPP configuration not completed (Configurator)")
  1363. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1364. if ev is None:
  1365. raise Exception("DPP configuration not completed (Enrollee)")
  1366. dev[0].request("DPP_STOP_LISTEN")
  1367. dev[0].dump_monitor()
  1368. def test_dpp_hostapd_configurator_responder(dev, apdev):
  1369. """DPP with hostapd as configurator/responder"""
  1370. check_dpp_capab(dev[0])
  1371. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1372. "channel": "1" })
  1373. check_dpp_capab(hapd)
  1374. cmd = "DPP_CONFIGURATOR_ADD"
  1375. res = hapd.request(cmd);
  1376. if "FAIL" in res:
  1377. raise Exception("Failed to add configurator")
  1378. conf_id = int(res)
  1379. hapd.set("dpp_configurator_params",
  1380. " conf=sta-dpp configurator=%d" % conf_id);
  1381. addr = hapd.own_addr().replace(':', '')
  1382. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1383. res = hapd.request(cmd)
  1384. if "FAIL" in res:
  1385. raise Exception("Failed to generate bootstrapping info")
  1386. id0 = int(res)
  1387. uri0 = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1388. res = dev[0].request("DPP_QR_CODE " + uri0)
  1389. if "FAIL" in res:
  1390. raise Exception("Failed to parse QR Code URI")
  1391. id1 = int(res)
  1392. cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % (id1)
  1393. if "OK" not in dev[0].request(cmd):
  1394. raise Exception("Failed to initiate DPP Authentication")
  1395. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1396. if ev is None:
  1397. raise Exception("DPP authentication did not succeed (Responder)")
  1398. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1399. if ev is None:
  1400. raise Exception("DPP authentication did not succeed (Initiator)")
  1401. ev = hapd.wait_event(["DPP-CONF-SENT"], timeout=5)
  1402. if ev is None:
  1403. raise Exception("DPP configuration not completed (Configurator)")
  1404. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1405. if ev is None:
  1406. raise Exception("DPP configuration not completed (Enrollee)")
  1407. dev[0].request("DPP_STOP_LISTEN")
  1408. dev[0].dump_monitor()
  1409. def test_dpp_own_config(dev, apdev):
  1410. """DPP configurator signing own connector"""
  1411. try:
  1412. run_dpp_own_config(dev, apdev)
  1413. finally:
  1414. dev[0].set("dpp_config_processing", "0")
  1415. def test_dpp_own_config_curve_mismatch(dev, apdev):
  1416. """DPP configurator signing own connector using mismatching curve"""
  1417. try:
  1418. run_dpp_own_config(dev, apdev, own_curve="BP-384", expect_failure=True)
  1419. finally:
  1420. dev[0].set("dpp_config_processing", "0")
  1421. def run_dpp_own_config(dev, apdev, own_curve=None, expect_failure=False):
  1422. check_dpp_capab(dev[0])
  1423. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" })
  1424. check_dpp_capab(hapd)
  1425. addr = hapd.own_addr().replace(':', '')
  1426. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1427. res = hapd.request(cmd)
  1428. if "FAIL" in res:
  1429. raise Exception("Failed to generate bootstrapping info")
  1430. id_h = int(res)
  1431. uri = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id_h)
  1432. cmd = "DPP_CONFIGURATOR_ADD"
  1433. res = dev[0].request(cmd);
  1434. if "FAIL" in res:
  1435. raise Exception("Failed to add configurator")
  1436. conf_id = int(res)
  1437. res = dev[0].request("DPP_QR_CODE " + uri)
  1438. if "FAIL" in res:
  1439. raise Exception("Failed to parse QR Code URI")
  1440. id = int(res)
  1441. cmd = "DPP_AUTH_INIT peer=%d conf=ap-dpp configurator=%d" % (id, conf_id)
  1442. if "OK" not in dev[0].request(cmd):
  1443. raise Exception("Failed to initiate DPP Authentication")
  1444. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1445. if ev is None:
  1446. raise Exception("DPP authentication did not succeed (Responder)")
  1447. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1448. if ev is None:
  1449. raise Exception("DPP authentication did not succeed (Initiator)")
  1450. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1451. if ev is None:
  1452. raise Exception("DPP configuration not completed (Configurator)")
  1453. ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1454. if ev is None:
  1455. raise Exception("DPP configuration not completed (Enrollee)")
  1456. update_hapd_config(hapd)
  1457. dev[0].set("dpp_config_processing", "1")
  1458. cmd = "DPP_CONFIGURATOR_SIGN conf=sta-dpp configurator=%d" % (conf_id)
  1459. if own_curve:
  1460. cmd += " curve=" + own_curve
  1461. res = dev[0].request(cmd)
  1462. if "FAIL" in res:
  1463. raise Exception("Failed to generate own configuration")
  1464. ev = dev[0].wait_event(["DPP-NETWORK-ID"], timeout=1)
  1465. if ev is None:
  1466. raise Exception("DPP network profile not generated")
  1467. id = ev.split(' ')[1]
  1468. dev[0].select_network(id, freq="2412")
  1469. if expect_failure:
  1470. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
  1471. if ev is not None:
  1472. raise Exception("Unexpected connection");
  1473. dev[0].request("DISCONNECT")
  1474. else:
  1475. dev[0].wait_connected()
  1476. def run_dpp_proto_init(dev, test_dev, test, mutual=False):
  1477. check_dpp_capab(dev[0])
  1478. check_dpp_capab(dev[1])
  1479. dev[test_dev].set("dpp_test", str(test))
  1480. cmd = "DPP_CONFIGURATOR_ADD"
  1481. res = dev[1].request(cmd);
  1482. if "FAIL" in res:
  1483. raise Exception("Failed to add configurator")
  1484. conf_id = int(res)
  1485. addr = dev[0].own_addr().replace(':', '')
  1486. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1487. res = dev[0].request(cmd)
  1488. if "FAIL" in res:
  1489. raise Exception("Failed to generate bootstrapping info")
  1490. id0 = int(res)
  1491. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1492. res = dev[1].request("DPP_QR_CODE " + uri0)
  1493. if "FAIL" in res:
  1494. raise Exception("Failed to parse QR Code URI")
  1495. id1 = int(res)
  1496. if mutual:
  1497. addr = dev[1].own_addr().replace(':', '')
  1498. res = dev[1].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  1499. if "FAIL" in res:
  1500. raise Exception("Failed to generate bootstrapping info")
  1501. id1b = int(res)
  1502. uri1b = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1b)
  1503. res = dev[0].request("DPP_QR_CODE " + uri1b)
  1504. if "FAIL" in res:
  1505. raise Exception("Failed to parse QR Code URI")
  1506. id0b = int(res)
  1507. cmd = "DPP_LISTEN 2412"
  1508. if "OK" not in dev[0].request(cmd):
  1509. raise Exception("Failed to start listen operation")
  1510. cmd = "DPP_AUTH_INIT peer=%d configurator=%d conf=sta-dpp" % (id1, conf_id)
  1511. if mutual:
  1512. cmd += " own=%d" % id1b
  1513. if "OK" not in dev[1].request(cmd):
  1514. raise Exception("Failed to initiate DPP Authentication")
  1515. def test_dpp_proto_after_wrapped_data_auth_req(dev, apdev):
  1516. """DPP protocol testing - attribute after Wrapped Data in Auth Req"""
  1517. run_dpp_proto_init(dev, 1, 1)
  1518. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  1519. if ev is None:
  1520. raise Exception("DPP Authentication Request not seen")
  1521. if "type=0" not in ev or "ignore=invalid-attributes" not in ev:
  1522. raise Exception("Unexpected RX info: " + ev)
  1523. ev = dev[1].wait_event(["DPP-RX"], timeout=0.1)
  1524. if ev is not None:
  1525. raise Exception("Unexpected DPP message seen")
  1526. def test_dpp_proto_after_wrapped_data_auth_resp(dev, apdev):
  1527. """DPP protocol testing - attribute after Wrapped Data in Auth Resp"""
  1528. run_dpp_proto_init(dev, 0, 2)
  1529. ev = dev[1].wait_event(["DPP-RX"], timeout=5)
  1530. if ev is None:
  1531. raise Exception("DPP Authentication Response not seen")
  1532. if "type=1" not in ev or "ignore=invalid-attributes" not in ev:
  1533. raise Exception("Unexpected RX info: " + ev)
  1534. ev = dev[0].wait_event(["DPP-RX"], timeout=1)
  1535. if ev is None or "type=0" not in ev:
  1536. raise Exception("DPP Authentication Request not seen")
  1537. ev = dev[0].wait_event(["DPP-RX"], timeout=0.1)
  1538. if ev is not None:
  1539. raise Exception("Unexpected DPP message seen")
  1540. def test_dpp_proto_after_wrapped_data_auth_conf(dev, apdev):
  1541. """DPP protocol testing - attribute after Wrapped Data in Auth Conf"""
  1542. run_dpp_proto_init(dev, 1, 3)
  1543. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  1544. if ev is None or "type=0" not in ev:
  1545. raise Exception("DPP Authentication Request not seen")
  1546. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  1547. if ev is None:
  1548. raise Exception("DPP Authentication Confirm not seen")
  1549. if "type=2" not in ev or "ignore=invalid-attributes" not in ev:
  1550. raise Exception("Unexpected RX info: " + ev)
  1551. def test_dpp_proto_after_wrapped_data_conf_req(dev, apdev):
  1552. """DPP protocol testing - attribute after Wrapped Data in Conf Req"""
  1553. run_dpp_proto_init(dev, 0, 6)
  1554. ev = dev[1].wait_event(["DPP-CONF-FAILED"], timeout=10)
  1555. if ev is None:
  1556. raise Exception("DPP Configuration failure not seen")
  1557. def test_dpp_proto_after_wrapped_data_conf_resp(dev, apdev):
  1558. """DPP protocol testing - attribute after Wrapped Data in Conf Resp"""
  1559. run_dpp_proto_init(dev, 1, 7)
  1560. ev = dev[0].wait_event(["DPP-CONF-FAILED"], timeout=10)
  1561. if ev is None:
  1562. raise Exception("DPP Configuration failure not seen")
  1563. def test_dpp_proto_zero_i_capab(dev, apdev):
  1564. """DPP protocol testing - zero I-capability in Auth Req"""
  1565. run_dpp_proto_init(dev, 1, 8)
  1566. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  1567. if ev is None:
  1568. raise Exception("DPP failure not seen")
  1569. if "Invalid role in I-capabilities 0x00" not in ev:
  1570. raise Exception("Unexpected failure: " + ev)
  1571. ev = dev[1].wait_event(["DPP-RX"], timeout=0.1)
  1572. if ev is not None:
  1573. raise Exception("Unexpected DPP message seen")
  1574. def test_dpp_proto_zero_r_capab(dev, apdev):
  1575. """DPP protocol testing - zero R-capability in Auth Resp"""
  1576. run_dpp_proto_init(dev, 0, 9)
  1577. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  1578. if ev is None:
  1579. raise Exception("DPP failure not seen")
  1580. if "Unexpected role in R-capabilities 0x00" not in ev:
  1581. raise Exception("Unexpected failure: " + ev)
  1582. ev = dev[0].wait_event(["DPP-RX"], timeout=1)
  1583. if ev is None or "type=0" not in ev:
  1584. raise Exception("DPP Authentication Request not seen")
  1585. ev = dev[0].wait_event(["DPP-RX"], timeout=0.1)
  1586. if ev is not None:
  1587. raise Exception("Unexpected DPP message seen")
  1588. def run_dpp_proto_auth_req_missing(dev, test, reason):
  1589. run_dpp_proto_init(dev, 1, test)
  1590. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  1591. if ev is None:
  1592. raise Exception("DPP failure not seen")
  1593. if reason not in ev:
  1594. raise Exception("Unexpected failure: " + ev)
  1595. ev = dev[1].wait_event(["DPP-RX"], timeout=0.1)
  1596. if ev is not None:
  1597. raise Exception("Unexpected DPP message seen")
  1598. def test_dpp_proto_auth_req_no_r_bootstrap_key(dev, apdev):
  1599. """DPP protocol testing - no R-bootstrap key in Auth Req"""
  1600. run_dpp_proto_auth_req_missing(dev, 10, "Missing or invalid required Responder Bootstrapping Key Hash attribute")
  1601. def test_dpp_proto_auth_req_no_i_bootstrap_key(dev, apdev):
  1602. """DPP protocol testing - no I-bootstrap key in Auth Req"""
  1603. run_dpp_proto_auth_req_missing(dev, 11, "Missing or invalid required Initiator Bootstrapping Key Hash attribute")
  1604. def test_dpp_proto_auth_req_no_i_proto_key(dev, apdev):
  1605. """DPP protocol testing - no I-proto key in Auth Req"""
  1606. run_dpp_proto_auth_req_missing(dev, 12, "Missing required Initiator Protocol Key attribute")
  1607. def test_dpp_proto_auth_req_no_i_nonce(dev, apdev):
  1608. """DPP protocol testing - no I-nonce in Auth Req"""
  1609. run_dpp_proto_auth_req_missing(dev, 13, "Missing or invalid I-nonce")
  1610. def test_dpp_proto_auth_req_no_i_capab(dev, apdev):
  1611. """DPP protocol testing - no I-capab in Auth Req"""
  1612. run_dpp_proto_auth_req_missing(dev, 14, "Missing or invalid I-capab")
  1613. def test_dpp_proto_auth_req_no_wrapped_data(dev, apdev):
  1614. """DPP protocol testing - no Wrapped Data in Auth Req"""
  1615. run_dpp_proto_auth_req_missing(dev, 15, "Missing or invalid required Wrapped Data attribute")
  1616. def run_dpp_proto_auth_resp_missing(dev, test, reason):
  1617. run_dpp_proto_init(dev, 0, test, mutual=True)
  1618. if reason is None:
  1619. time.sleep(0.1)
  1620. return
  1621. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  1622. if ev is None:
  1623. raise Exception("DPP failure not seen")
  1624. if reason not in ev:
  1625. raise Exception("Unexpected failure: " + ev)
  1626. ev = dev[0].wait_event(["DPP-RX"], timeout=1)
  1627. if ev is None or "type=0" not in ev:
  1628. raise Exception("DPP Authentication Request not seen")
  1629. ev = dev[0].wait_event(["DPP-RX"], timeout=0.1)
  1630. if ev is not None:
  1631. raise Exception("Unexpected DPP message seen")
  1632. def test_dpp_proto_auth_resp_no_status(dev, apdev):
  1633. """DPP protocol testing - no Status in Auth Resp"""
  1634. run_dpp_proto_auth_resp_missing(dev, 16, "Missing or invalid required DPP Status attribute")
  1635. def test_dpp_proto_auth_resp_no_r_bootstrap_key(dev, apdev):
  1636. """DPP protocol testing - no R-bootstrap key in Auth Resp"""
  1637. run_dpp_proto_auth_resp_missing(dev, 17, "Missing or invalid required Responder Bootstrapping Key Hash attribute")
  1638. def test_dpp_proto_auth_resp_no_i_bootstrap_key(dev, apdev):
  1639. """DPP protocol testing - no I-bootstrap key in Auth Resp"""
  1640. run_dpp_proto_auth_resp_missing(dev, 18, None)
  1641. def test_dpp_proto_auth_resp_no_r_proto_key(dev, apdev):
  1642. """DPP protocol testing - no R-Proto Key in Auth Resp"""
  1643. run_dpp_proto_auth_resp_missing(dev, 19, "Missing required Responder Protocol Key attribute")
  1644. def test_dpp_proto_auth_resp_no_r_nonce(dev, apdev):
  1645. """DPP protocol testing - no R-nonce in Auth Resp"""
  1646. run_dpp_proto_auth_resp_missing(dev, 20, "Missing or invalid R-nonce")
  1647. def test_dpp_proto_auth_resp_no_i_nonce(dev, apdev):
  1648. """DPP protocol testing - no I-nonce in Auth Resp"""
  1649. run_dpp_proto_auth_resp_missing(dev, 21, "Missing or invalid I-nonce")
  1650. def test_dpp_proto_auth_resp_no_r_capab(dev, apdev):
  1651. """DPP protocol testing - no R-capab in Auth Resp"""
  1652. run_dpp_proto_auth_resp_missing(dev, 22, "Missing or invalid R-capabilities")
  1653. def test_dpp_proto_auth_resp_no_r_auth(dev, apdev):
  1654. """DPP protocol testing - no R-auth in Auth Resp"""
  1655. run_dpp_proto_auth_resp_missing(dev, 23, "Missing or invalid Secondary Wrapped Data")
  1656. def test_dpp_proto_auth_resp_no_wrapped_data(dev, apdev):
  1657. """DPP protocol testing - no Wrapped Data in Auth Resp"""
  1658. run_dpp_proto_auth_resp_missing(dev, 24, "Missing or invalid required Wrapped Data attribute")
  1659. def test_dpp_proto_auth_resp_i_nonce_mismatch(dev, apdev):
  1660. """DPP protocol testing - I-nonce mismatch in Auth Resp"""
  1661. run_dpp_proto_init(dev, 0, 30, mutual=True)
  1662. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  1663. if ev is None:
  1664. raise Exception("DPP failure not seen")
  1665. if "I-nonce mismatch" not in ev:
  1666. raise Exception("Unexpected failure: " + ev)
  1667. ev = dev[0].wait_event(["DPP-RX"], timeout=1)
  1668. if ev is None or "type=0" not in ev:
  1669. raise Exception("DPP Authentication Request not seen")
  1670. ev = dev[0].wait_event(["DPP-RX"], timeout=0.1)
  1671. if ev is not None:
  1672. raise Exception("Unexpected DPP message seen")
  1673. def test_dpp_proto_auth_resp_incompatible_r_capab(dev, apdev):
  1674. """DPP protocol testing - Incompatible R-capab in Auth Resp"""
  1675. run_dpp_proto_init(dev, 0, 31, mutual=True)
  1676. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  1677. if ev is None:
  1678. raise Exception("DPP failure not seen")
  1679. if "Unexpected role in R-capabilities 0x02" not in ev:
  1680. raise Exception("Unexpected failure: " + ev)
  1681. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  1682. if ev is None:
  1683. raise Exception("DPP failure not seen")
  1684. if "Peer reported incompatible R-capab role" not in ev:
  1685. raise Exception("Unexpected failure: " + ev)
  1686. def test_dpp_proto_auth_resp_r_auth_mismatch(dev, apdev):
  1687. """DPP protocol testing - R-auth mismatch in Auth Resp"""
  1688. run_dpp_proto_init(dev, 0, 32, mutual=True)
  1689. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  1690. if ev is None:
  1691. raise Exception("DPP failure not seen")
  1692. if "Mismatching Responder Authenticating Tag" not in ev:
  1693. raise Exception("Unexpected failure: " + ev)
  1694. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  1695. if ev is None:
  1696. raise Exception("DPP failure not seen")
  1697. if "Peer reported authentication failure" not in ev:
  1698. raise Exception("Unexpected failure: " + ev)
  1699. def run_dpp_proto_auth_conf_missing(dev, test, reason):
  1700. run_dpp_proto_init(dev, 1, test, mutual=True)
  1701. if reason is None:
  1702. time.sleep(0.1)
  1703. return
  1704. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  1705. if ev is None:
  1706. raise Exception("DPP failure not seen")
  1707. if reason not in ev:
  1708. raise Exception("Unexpected failure: " + ev)
  1709. def test_dpp_proto_auth_conf_no_status(dev, apdev):
  1710. """DPP protocol testing - no Status in Auth Conf"""
  1711. run_dpp_proto_auth_conf_missing(dev, 25, "Missing or invalid required DPP Status attribute")
  1712. def test_dpp_proto_auth_conf_no_r_bootstrap_key(dev, apdev):
  1713. """DPP protocol testing - no R-bootstrap key in Auth Conf"""
  1714. run_dpp_proto_auth_conf_missing(dev, 26, "Missing or invalid required Responder Bootstrapping Key Hash attribute")
  1715. def test_dpp_proto_auth_conf_no_i_bootstrap_key(dev, apdev):
  1716. """DPP protocol testing - no I-bootstrap key in Auth Conf"""
  1717. run_dpp_proto_auth_conf_missing(dev, 27, "Missing Initiator Bootstrapping Key Hash attribute")
  1718. def test_dpp_proto_auth_conf_no_i_auth(dev, apdev):
  1719. """DPP protocol testing - no I-Auth in Auth Conf"""
  1720. run_dpp_proto_auth_conf_missing(dev, 28, "Missing or invalid Initiator Authenticating Tag")
  1721. def test_dpp_proto_auth_conf_no_wrapped_data(dev, apdev):
  1722. """DPP protocol testing - no Wrapped Data in Auth Conf"""
  1723. run_dpp_proto_auth_conf_missing(dev, 29, "Missing or invalid required Wrapped Data attribute")
  1724. def test_dpp_proto_auth_conf_i_auth_mismatch(dev, apdev):
  1725. """DPP protocol testing - I-auth mismatch in Auth Conf"""
  1726. run_dpp_proto_init(dev, 1, 33, mutual=True)
  1727. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  1728. if ev is None:
  1729. raise Exception("DPP failure not seen")
  1730. if "Mismatching Initiator Authenticating Tag" not in ev:
  1731. raise Excception("Unexpected failure: " + ev)
  1732. def run_dpp_proto_init_pkex(dev, test_dev, test):
  1733. check_dpp_capab(dev[0])
  1734. check_dpp_capab(dev[1])
  1735. dev[test_dev].set("dpp_test", str(test))
  1736. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1737. res = dev[0].request(cmd)
  1738. if "FAIL" in res:
  1739. raise Exception("Failed to generate bootstrapping info")
  1740. id0 = int(res)
  1741. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1742. res = dev[1].request(cmd)
  1743. if "FAIL" in res:
  1744. raise Exception("Failed to generate bootstrapping info")
  1745. id1 = int(res)
  1746. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1747. res = dev[0].request(cmd)
  1748. if "FAIL" in res:
  1749. raise Exception("Failed to set PKEX data (responder)")
  1750. cmd = "DPP_LISTEN 2437"
  1751. if "OK" not in dev[0].request(cmd):
  1752. raise Exception("Failed to start listen operation")
  1753. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 code=secret" % id1
  1754. res = dev[1].request(cmd)
  1755. if "FAIL" in res:
  1756. raise Exception("Failed to set PKEX data (initiator)")
  1757. def test_dpp_proto_after_wrapped_data_pkex_cr_req(dev, apdev):
  1758. """DPP protocol testing - attribute after Wrapped Data in PKEX CR Req"""
  1759. run_dpp_proto_init_pkex(dev, 1, 4)
  1760. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  1761. if ev is None or "type=7" not in ev:
  1762. raise Exception("PKEX Exchange Request not seen")
  1763. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  1764. if ev is None or "type=9" not in ev:
  1765. raise Exception("PKEX Commit-Reveal Request not seen")
  1766. if "ignore=invalid-attributes" not in ev:
  1767. raise Exception("Unexpected RX info: " + ev)
  1768. def test_dpp_proto_after_wrapped_data_pkex_cr_resp(dev, apdev):
  1769. """DPP protocol testing - attribute after Wrapped Data in PKEX CR Resp"""
  1770. run_dpp_proto_init_pkex(dev, 0, 5)
  1771. ev = dev[1].wait_event(["DPP-RX"], timeout=5)
  1772. if ev is None or "type=8" not in ev:
  1773. raise Exception("PKEX Exchange Response not seen")
  1774. ev = dev[1].wait_event(["DPP-RX"], timeout=5)
  1775. if ev is None or "type=10" not in ev:
  1776. raise Exception("PKEX Commit-Reveal Response not seen")
  1777. if "ignore=invalid-attributes" not in ev:
  1778. raise Exception("Unexpected RX info: " + ev)