test_dpp.py 121 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899
  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_auth_hostapd_mutual2(dev, apdev):
  337. """DPP QR Code and authentication exchange (hostapd mutual2)"""
  338. check_dpp_capab(dev[0])
  339. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" })
  340. check_dpp_capab(hapd)
  341. logger.info("AP displays QR Code")
  342. addr = hapd.own_addr().replace(':', '')
  343. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  344. res = hapd.request(cmd)
  345. if "FAIL" in res:
  346. raise Exception("Failed to generate bootstrapping info")
  347. id_h = int(res)
  348. uri_h = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id_h)
  349. logger.info("dev0 scans QR Code")
  350. res = dev[0].request("DPP_QR_CODE " + uri_h)
  351. if "FAIL" in res:
  352. raise Exception("Failed to parse QR Code URI")
  353. id0 = int(res)
  354. logger.info("dev0 displays QR Code")
  355. addr = dev[0].own_addr().replace(':', '')
  356. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  357. if "FAIL" in res:
  358. raise Exception("Failed to generate bootstrapping info")
  359. id0b = int(res)
  360. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0b)
  361. logger.info("dev0 initiates DPP Authentication")
  362. if "OK" not in hapd.request("DPP_LISTEN 2412 qr=mutual"):
  363. raise Exception("Failed to start listen operation")
  364. if "OK" not in dev[0].request("DPP_AUTH_INIT peer=%d own=%d" % (id0, id0b)):
  365. raise Exception("Failed to initiate DPP Authentication")
  366. ev = dev[0].wait_event(["DPP-RESPONSE-PENDING"], timeout=5)
  367. if ev is None:
  368. raise Exception("Pending response not reported")
  369. ev = hapd.wait_event(["DPP-SCAN-PEER-QR-CODE"], timeout=5)
  370. if ev is None:
  371. raise Exception("QR Code scan for mutual authentication not requested")
  372. logger.info("AP scans QR Code")
  373. res = hapd.request("DPP_QR_CODE " + uri0)
  374. if "FAIL" in res:
  375. raise Exception("Failed to parse QR Code URI")
  376. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  377. if ev is None:
  378. raise Exception("DPP authentication did not succeed (Responder)")
  379. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  380. if ev is None:
  381. raise Exception("DPP authentication did not succeed (Initiator)")
  382. hapd.request("DPP_STOP_LISTEN")
  383. def test_dpp_qr_code_listen_continue(dev, apdev):
  384. """DPP QR Code and listen operation needing continuation"""
  385. check_dpp_capab(dev[0])
  386. check_dpp_capab(dev[1])
  387. logger.info("dev0 displays QR Code")
  388. addr = dev[0].own_addr().replace(':', '')
  389. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  390. if "FAIL" in res:
  391. raise Exception("Failed to generate bootstrapping info")
  392. id0 = int(res)
  393. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  394. logger.info("dev1 scans QR Code")
  395. res = dev[1].request("DPP_QR_CODE " + uri0)
  396. if "FAIL" in res:
  397. raise Exception("Failed to parse QR Code URI")
  398. id1 = int(res)
  399. if "OK" not in dev[0].request("DPP_LISTEN 2412"):
  400. raise Exception("Failed to start listen operation")
  401. logger.info("Wait for listen to expire and get restarted")
  402. time.sleep(5.5)
  403. logger.info("dev1 initiates DPP Authentication")
  404. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d" % id1):
  405. raise Exception("Failed to initiate DPP Authentication")
  406. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  407. if ev is None:
  408. raise Exception("DPP authentication did not succeed (Responder)")
  409. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  410. if ev is None:
  411. raise Exception("DPP authentication did not succeed (Initiator)")
  412. dev[0].request("DPP_STOP_LISTEN")
  413. def test_dpp_qr_code_auth_initiator_enrollee(dev, apdev):
  414. """DPP QR Code and authentication exchange (Initiator in Enrollee role)"""
  415. check_dpp_capab(dev[0])
  416. check_dpp_capab(dev[1])
  417. dev[0].request("SET gas_address3 1")
  418. dev[1].request("SET gas_address3 1")
  419. logger.info("dev0 displays QR Code")
  420. addr = dev[0].own_addr().replace(':', '')
  421. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  422. if "FAIL" in res:
  423. raise Exception("Failed to generate bootstrapping info")
  424. id0 = int(res)
  425. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  426. logger.info("dev1 scans QR Code")
  427. res = dev[1].request("DPP_QR_CODE " + uri0)
  428. if "FAIL" in res:
  429. raise Exception("Failed to parse QR Code URI")
  430. id1 = int(res)
  431. logger.info("dev1 initiates DPP Authentication")
  432. if "OK" not in dev[0].request("DPP_LISTEN 2412"):
  433. raise Exception("Failed to start listen operation")
  434. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=enrollee" % id1):
  435. raise Exception("Failed to initiate DPP Authentication")
  436. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  437. if ev is None:
  438. raise Exception("DPP authentication did not succeed (Responder)")
  439. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  440. if ev is None:
  441. raise Exception("DPP authentication did not succeed (Initiator)")
  442. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  443. if ev is None:
  444. raise Exception("DPP configuration did not succeed (Configurator)")
  445. ev = dev[1].wait_event(["DPP-CONF-FAILED"], timeout=5)
  446. if ev is None:
  447. raise Exception("DPP configuration did not succeed (Enrollee)")
  448. dev[0].request("DPP_STOP_LISTEN")
  449. def test_dpp_qr_code_auth_incompatible_roles(dev, apdev):
  450. """DPP QR Code and authentication exchange (incompatible roles)"""
  451. check_dpp_capab(dev[0])
  452. check_dpp_capab(dev[1])
  453. logger.info("dev0 displays QR Code")
  454. addr = dev[0].own_addr().replace(':', '')
  455. res = dev[0].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  456. if "FAIL" in res:
  457. raise Exception("Failed to generate bootstrapping info")
  458. id0 = int(res)
  459. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  460. logger.info("dev1 scans QR Code")
  461. res = dev[1].request("DPP_QR_CODE " + uri0)
  462. if "FAIL" in res:
  463. raise Exception("Failed to parse QR Code URI")
  464. id1 = int(res)
  465. logger.info("dev1 initiates DPP Authentication")
  466. if "OK" not in dev[0].request("DPP_LISTEN 2412 role=enrollee"):
  467. raise Exception("Failed to start listen operation")
  468. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=enrollee" % id1):
  469. raise Exception("Failed to initiate DPP Authentication")
  470. ev = dev[1].wait_event(["DPP-NOT-COMPATIBLE"], timeout=5)
  471. if ev is None:
  472. raise Exception("DPP-NOT-COMPATIBLE event on initiator timed out")
  473. ev = dev[0].wait_event(["DPP-NOT-COMPATIBLE"], timeout=1)
  474. if ev is None:
  475. raise Exception("DPP-NOT-COMPATIBLE event on responder timed out")
  476. if "OK" not in dev[1].request("DPP_AUTH_INIT peer=%d role=configurator" % id1):
  477. raise Exception("Failed to initiate DPP Authentication")
  478. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  479. if ev is None:
  480. raise Exception("DPP authentication did not succeed (Responder)")
  481. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  482. if ev is None:
  483. raise Exception("DPP authentication did not succeed (Initiator)")
  484. dev[0].request("DPP_STOP_LISTEN")
  485. def test_dpp_qr_code_auth_neg_chan(dev, apdev):
  486. """DPP QR Code and authentication exchange with requested different channel"""
  487. check_dpp_capab(dev[0])
  488. check_dpp_capab(dev[1])
  489. logger.info("Create configurator on dev1")
  490. cmd = "DPP_CONFIGURATOR_ADD"
  491. res = dev[1].request(cmd);
  492. if "FAIL" in res:
  493. raise Exception("Failed to add configurator")
  494. conf_id = int(res)
  495. logger.info("dev0 displays QR Code")
  496. addr = dev[0].own_addr().replace(':', '')
  497. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  498. res = dev[0].request(cmd)
  499. if "FAIL" in res:
  500. raise Exception("Failed to generate bootstrapping info")
  501. id0 = int(res)
  502. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  503. logger.info("dev1 scans QR Code")
  504. res = dev[1].request("DPP_QR_CODE " + uri0)
  505. if "FAIL" in res:
  506. raise Exception("Failed to parse QR Code URI")
  507. id1 = int(res)
  508. logger.info("dev1 initiates DPP Authentication")
  509. cmd = "DPP_LISTEN 2412"
  510. if "OK" not in dev[0].request(cmd):
  511. raise Exception("Failed to start listen operation")
  512. cmd = "DPP_AUTH_INIT peer=%d configurator=%d conf=sta-dpp neg_freq=2462" % (id1, conf_id)
  513. if "OK" not in dev[1].request(cmd):
  514. raise Exception("Failed to initiate DPP Authentication")
  515. ev = dev[1].wait_event(["DPP-TX"], timeout=5)
  516. if ev is None:
  517. raise Exception("DPP Authentication Request not sent")
  518. if "freq=2412 type=0" not in ev:
  519. raise Exception("Unexpected TX data for Authentication Request: " + ev)
  520. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  521. if ev is None:
  522. raise Exception("DPP Authentication Request not received")
  523. if "freq=2412 type=0" not in ev:
  524. raise Exception("Unexpected RX data for Authentication Request: " + ev)
  525. ev = dev[1].wait_event(["DPP-TX-STATUS"], timeout=5)
  526. if ev is None:
  527. raise Exception("TX status for DPP Authentication Request not reported")
  528. if "freq=2412 result=SUCCESS" not in ev:
  529. raise Exception("Unexpected TX status for Authentication Request: " + ev)
  530. ev = dev[0].wait_event(["DPP-TX"], timeout=5)
  531. if ev is None:
  532. raise Exception("DPP Authentication Response not sent")
  533. if "freq=2462 type=1" not in ev:
  534. raise Exception("Unexpected TX data for Authentication Response: " + ev)
  535. ev = dev[1].wait_event(["DPP-RX"], timeout=5)
  536. if ev is None:
  537. raise Exception("DPP Authentication Response not received")
  538. if "freq=2462 type=1" not in ev:
  539. raise Exception("Unexpected RX data for Authentication Response: " + ev)
  540. ev = dev[0].wait_event(["DPP-TX-STATUS"], timeout=5)
  541. if ev is None:
  542. raise Exception("TX status for DPP Authentication Response not reported")
  543. if "freq=2462 result=SUCCESS" not in ev:
  544. raise Exception("Unexpected TX status for Authentication Response: " + ev)
  545. ev = dev[1].wait_event(["DPP-TX"], timeout=5)
  546. if ev is None:
  547. raise Exception("DPP Authentication Confirm not sent")
  548. if "freq=2462 type=2" not in ev:
  549. raise Exception("Unexpected TX data for Authentication Confirm: " + ev)
  550. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  551. if ev is None:
  552. raise Exception("DPP Authentication Confirm not received")
  553. if "freq=2462 type=2" not in ev:
  554. raise Exception("Unexpected RX data for Authentication Confirm: " + ev)
  555. ev = dev[1].wait_event(["DPP-TX-STATUS"], timeout=5)
  556. if ev is None:
  557. raise Exception("TX status for DPP Authentication Confirm not reported")
  558. if "freq=2462 result=SUCCESS" not in ev:
  559. raise Exception("Unexpected TX status for Authentication Confirm: " + ev)
  560. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  561. if ev is None:
  562. raise Exception("DPP authentication did not succeed (Responder)")
  563. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  564. if ev is None:
  565. raise Exception("DPP authentication did not succeed (Initiator)")
  566. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=5)
  567. if ev is None:
  568. raise Exception("DPP configuration not completed (Configurator)")
  569. ev = dev[0].wait_event(["DPP-CONF-RECEIVED", "DPP-CONF-FAILED"], timeout=5)
  570. if ev is None:
  571. raise Exception("DPP configuration not completed (Enrollee)")
  572. if "DPP-CONF-FAILED" in ev:
  573. raise Exception("DPP configuration failed")
  574. dev[0].request("DPP_STOP_LISTEN")
  575. dev[0].dump_monitor()
  576. dev[1].dump_monitor()
  577. def test_dpp_config_legacy(dev, apdev):
  578. """DPP Config Object for legacy network using passphrase"""
  579. check_dpp_capab(dev[1])
  580. conf = '{"wi-fi_tech":"infra", "discovery":{"ssid":"test"},"cred":{"akm":"psk","pass":"secret passphrase"}}'
  581. dev[1].set("dpp_config_obj_override", conf)
  582. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  583. require_conf_success=True)
  584. def test_dpp_config_legacy_psk_hex(dev, apdev):
  585. """DPP Config Object for legacy network using PSK"""
  586. check_dpp_capab(dev[1])
  587. conf = '{"wi-fi_tech":"infra", "discovery":{"ssid":"test"},"cred":{"akm":"psk","psk_hex":"' + 32*"12" + '"}}'
  588. dev[1].set("dpp_config_obj_override", conf)
  589. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  590. require_conf_success=True)
  591. def test_dpp_config_fragmentation(dev, apdev):
  592. """DPP Config Object for legacy network requiring fragmentation"""
  593. check_dpp_capab(dev[1])
  594. conf = '{"wi-fi_tech":"infra", "discovery":{"ssid":"test"},"cred":{"akm":"psk","pass":"secret passphrase"}}' + 3000*' '
  595. dev[1].set("dpp_config_obj_override", conf)
  596. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  597. require_conf_success=True)
  598. def test_dpp_config_legacy_gen(dev, apdev):
  599. """Generate DPP Config Object for legacy network"""
  600. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  601. init_extra="conf=sta-psk pass=%s" % "passphrase".encode("hex"),
  602. require_conf_success=True)
  603. def test_dpp_config_dpp_gen_prime256v1(dev, apdev):
  604. """Generate DPP Config Object for DPP network (P-256)"""
  605. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  606. init_extra="conf=sta-dpp",
  607. require_conf_success=True,
  608. configurator=True)
  609. def test_dpp_config_dpp_gen_secp384r1(dev, apdev):
  610. """Generate DPP Config Object for DPP network (P-384)"""
  611. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  612. init_extra="conf=sta-dpp",
  613. require_conf_success=True,
  614. configurator=True)
  615. def test_dpp_config_dpp_gen_secp521r1(dev, apdev):
  616. """Generate DPP Config Object for DPP network (P-521)"""
  617. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  618. init_extra="conf=sta-dpp",
  619. require_conf_success=True,
  620. configurator=True)
  621. def test_dpp_config_dpp_gen_prime256v1_prime256v1(dev, apdev):
  622. """Generate DPP Config Object for DPP network (P-256 + P-256)"""
  623. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  624. init_extra="conf=sta-dpp",
  625. require_conf_success=True,
  626. configurator=True,
  627. conf_curve="prime256v1")
  628. def test_dpp_config_dpp_gen_prime256v1_secp384r1(dev, apdev):
  629. """Generate DPP Config Object for DPP network (P-256 + P-384)"""
  630. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  631. init_extra="conf=sta-dpp",
  632. require_conf_success=True,
  633. configurator=True,
  634. conf_curve="secp384r1")
  635. def test_dpp_config_dpp_gen_prime256v1_secp521r1(dev, apdev):
  636. """Generate DPP Config Object for DPP network (P-256 + P-521)"""
  637. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  638. init_extra="conf=sta-dpp",
  639. require_conf_success=True,
  640. configurator=True,
  641. conf_curve="secp521r1")
  642. def test_dpp_config_dpp_gen_secp384r1_prime256v1(dev, apdev):
  643. """Generate DPP Config Object for DPP network (P-384 + P-256)"""
  644. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  645. init_extra="conf=sta-dpp",
  646. require_conf_success=True,
  647. configurator=True,
  648. conf_curve="prime256v1")
  649. def test_dpp_config_dpp_gen_secp384r1_secp384r1(dev, apdev):
  650. """Generate DPP Config Object for DPP network (P-384 + P-384)"""
  651. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  652. init_extra="conf=sta-dpp",
  653. require_conf_success=True,
  654. configurator=True,
  655. conf_curve="secp384r1")
  656. def test_dpp_config_dpp_gen_secp384r1_secp521r1(dev, apdev):
  657. """Generate DPP Config Object for DPP network (P-384 + P-521)"""
  658. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  659. init_extra="conf=sta-dpp",
  660. require_conf_success=True,
  661. configurator=True,
  662. conf_curve="secp521r1")
  663. def test_dpp_config_dpp_gen_secp521r1_prime256v1(dev, apdev):
  664. """Generate DPP Config Object for DPP network (P-521 + P-256)"""
  665. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  666. init_extra="conf=sta-dpp",
  667. require_conf_success=True,
  668. configurator=True,
  669. conf_curve="prime256v1")
  670. def test_dpp_config_dpp_gen_secp521r1_secp384r1(dev, apdev):
  671. """Generate DPP Config Object for DPP network (P-521 + P-384)"""
  672. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  673. init_extra="conf=sta-dpp",
  674. require_conf_success=True,
  675. configurator=True,
  676. conf_curve="secp384r1")
  677. def test_dpp_config_dpp_gen_secp521r1_secp521r1(dev, apdev):
  678. """Generate DPP Config Object for DPP network (P-521 + P-521)"""
  679. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  680. init_extra="conf=sta-dpp",
  681. require_conf_success=True,
  682. configurator=True,
  683. conf_curve="secp521r1")
  684. def test_dpp_config_dpp_gen_expiry(dev, apdev):
  685. """Generate DPP Config Object for DPP network with expiry value"""
  686. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  687. init_extra="conf=sta-dpp expiry=%d" % (time.time() + 1000),
  688. require_conf_success=True,
  689. configurator=True)
  690. def test_dpp_config_dpp_gen_expired_key(dev, apdev):
  691. """Generate DPP Config Object for DPP network with expiry value"""
  692. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  693. init_extra="conf=sta-dpp expiry=%d" % (time.time() - 10),
  694. require_conf_failure=True,
  695. configurator=True)
  696. def test_dpp_config_dpp_override_prime256v1(dev, apdev):
  697. """DPP Config Object override (P-256)"""
  698. check_dpp_capab(dev[0])
  699. check_dpp_capab(dev[1])
  700. 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"}}}'
  701. dev[0].set("dpp_ignore_netaccesskey_mismatch", "1")
  702. dev[1].set("dpp_config_obj_override", conf)
  703. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  704. require_conf_success=True)
  705. def test_dpp_config_dpp_override_secp384r1(dev, apdev):
  706. """DPP Config Object override (P-384)"""
  707. check_dpp_capab(dev[0])
  708. check_dpp_capab(dev[1])
  709. 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"}}}'
  710. dev[0].set("dpp_ignore_netaccesskey_mismatch", "1")
  711. dev[1].set("dpp_config_obj_override", conf)
  712. run_dpp_qr_code_auth_unicast(dev, apdev, "secp384r1",
  713. require_conf_success=True)
  714. def test_dpp_config_dpp_override_secp521r1(dev, apdev):
  715. """DPP Config Object override (P-521)"""
  716. check_dpp_capab(dev[0])
  717. check_dpp_capab(dev[1])
  718. 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"}}}'
  719. dev[0].set("dpp_ignore_netaccesskey_mismatch", "1")
  720. dev[1].set("dpp_config_obj_override", conf)
  721. run_dpp_qr_code_auth_unicast(dev, apdev, "secp521r1",
  722. require_conf_success=True)
  723. def test_dpp_config_override_objects(dev, apdev):
  724. """Generate DPP Config Object and override objects)"""
  725. check_dpp_capab(dev[1])
  726. discovery = '{\n"ssid":"mywifi"\n}'
  727. groups = '[\n {"groupId":"home","netRole":"sta"},\n {"groupId":"cottage","netRole":"sta"}\n]'
  728. dev[1].set("dpp_discovery_override", discovery)
  729. dev[1].set("dpp_groups_override", groups)
  730. run_dpp_qr_code_auth_unicast(dev, apdev, "prime256v1",
  731. init_extra="conf=sta-dpp",
  732. require_conf_success=True,
  733. configurator=True)
  734. def test_dpp_gas_timeout(dev, apdev):
  735. """DPP and GAS server timeout for a query"""
  736. check_dpp_capab(dev[0])
  737. check_dpp_capab(dev[1])
  738. logger.info("dev0 displays QR Code")
  739. addr = dev[0].own_addr().replace(':', '')
  740. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  741. res = dev[0].request(cmd)
  742. if "FAIL" in res:
  743. raise Exception("Failed to generate bootstrapping info")
  744. id0 = int(res)
  745. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  746. logger.info("dev1 scans QR Code")
  747. res = dev[1].request("DPP_QR_CODE " + uri0)
  748. if "FAIL" in res:
  749. raise Exception("Failed to parse QR Code URI")
  750. id1 = int(res)
  751. logger.info("dev1 initiates DPP Authentication")
  752. dev[0].set("ext_mgmt_frame_handling", "1")
  753. cmd = "DPP_LISTEN 2412"
  754. if "OK" not in dev[0].request(cmd):
  755. raise Exception("Failed to start listen operation")
  756. # Force GAS fragmentation
  757. conf = '{"wi-fi_tech":"infra", "discovery":{"ssid":"test"},"cred":{"akm":"psk","pass":"secret passphrase"}}' + 3000*' '
  758. dev[1].set("dpp_config_obj_override", conf)
  759. cmd = "DPP_AUTH_INIT peer=%d" % id1
  760. if "OK" not in dev[1].request(cmd):
  761. raise Exception("Failed to initiate DPP Authentication")
  762. # DPP Authentication Request
  763. msg = dev[0].mgmt_rx()
  764. 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'))):
  765. raise Exception("MGMT_RX_PROCESS failed")
  766. # DPP Authentication Confirmation
  767. msg = dev[0].mgmt_rx()
  768. 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'))):
  769. raise Exception("MGMT_RX_PROCESS failed")
  770. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  771. if ev is None:
  772. raise Exception("DPP authentication did not succeed (Responder)")
  773. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  774. if ev is None:
  775. raise Exception("DPP authentication did not succeed (Initiator)")
  776. # DPP Configuration Response (GAS Initial Response frame)
  777. msg = dev[0].mgmt_rx()
  778. 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'))):
  779. raise Exception("MGMT_RX_PROCESS failed")
  780. # GAS Comeback Response frame
  781. msg = dev[0].mgmt_rx()
  782. # Do not continue to force timeout on GAS server
  783. ev = dev[0].wait_event(["GAS-QUERY-DONE"], timeout=10)
  784. if ev is None:
  785. raise Exception("GAS result not reported (Enrollee)")
  786. if "result=TIMEOUT" not in ev:
  787. raise Exception("Unexpected GAS result (Enrollee): " + ev)
  788. dev[0].set("ext_mgmt_frame_handling", "0")
  789. ev = dev[1].wait_event(["DPP-CONF-FAILED"], timeout=15)
  790. if ev is None:
  791. raise Exception("DPP configuration failure not reported (Configurator)")
  792. ev = dev[0].wait_event(["DPP-CONF-FAILED"], timeout=1)
  793. if ev is None:
  794. raise Exception("DPP configuration failure not reported (Enrollee)")
  795. def test_dpp_akm_sha256(dev, apdev):
  796. """DPP AKM (SHA256)"""
  797. run_dpp_akm(dev, apdev, 32)
  798. def test_dpp_akm_sha384(dev, apdev):
  799. """DPP AKM (SHA384)"""
  800. run_dpp_akm(dev, apdev, 48)
  801. def test_dpp_akm_sha512(dev, apdev):
  802. """DPP AKM (SHA512)"""
  803. run_dpp_akm(dev, apdev, 64)
  804. def run_dpp_akm(dev, apdev, pmk_len):
  805. check_dpp_capab(dev[0])
  806. check_dpp_capab(dev[1])
  807. params = { "ssid": "dpp",
  808. "wpa": "2",
  809. "wpa_key_mgmt": "DPP",
  810. "rsn_pairwise": "CCMP",
  811. "ieee80211w": "2" }
  812. try:
  813. hapd = hostapd.add_ap(apdev[0], params)
  814. except:
  815. raise HwsimSkip("DPP not supported")
  816. id = dev[0].connect("dpp", key_mgmt="DPP", ieee80211w="2", scan_freq="2412",
  817. wait_connect=False)
  818. ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=2)
  819. if not ev:
  820. raise Exception("Network mismatch not reported")
  821. dev[0].request("DISCONNECT")
  822. dev[0].dump_monitor()
  823. bssid = hapd.own_addr()
  824. pmkid = 16*'11'
  825. akmp = 2**23
  826. pmk = pmk_len*'22'
  827. cmd = "PMKSA_ADD %d %s %s %s 30240 43200 %d 0" % (id, bssid, pmkid, pmk, akmp)
  828. if "OK" not in dev[0].request(cmd):
  829. raise Exception("PMKSA_ADD failed (wpa_supplicant)")
  830. dev[0].select_network(id, freq="2412")
  831. ev = dev[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"], timeout=2)
  832. dev[0].request("DISCONNECT")
  833. dev[0].dump_monitor()
  834. if not ev:
  835. raise Exception("Association attempt was not rejected")
  836. if "status_code=53" not in ev:
  837. raise Exception("Unexpected status code: " + ev)
  838. addr = dev[0].own_addr()
  839. cmd = "PMKSA_ADD %s %s %s 0 %d" % (addr, pmkid, pmk, akmp)
  840. if "OK" not in hapd.request(cmd):
  841. raise Exception("PMKSA_ADD failed (hostapd)")
  842. dev[0].select_network(id, freq="2412")
  843. dev[0].wait_connected()
  844. val = dev[0].get_status_field("key_mgmt")
  845. if val != "DPP":
  846. raise Exception("Unexpected key_mgmt: " + val)
  847. def test_dpp_network_introduction(dev, apdev):
  848. """DPP network introduction"""
  849. check_dpp_capab(dev[0])
  850. check_dpp_capab(dev[1])
  851. csign = "3059301306072a8648ce3d020106082a8648ce3d03010703420004d02e5bd81a120762b5f0f2994777f5d40297238a6c294fd575cdf35fabec44c050a6421c401d98d659fd2ed13c961cc8287944dd3202f516977800d3ab2f39ee"
  852. ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIwOHF4TlNYRzRWemdCV3BjVUdNSmc1czNvbElOVFJsRVQ1aERpNkRKY3ZjIiwieSI6IlVhaGFYQXpKRVpRQk1YaHRUQnlZZVlrOWtJYjk5UDA3UV9NcW9TVVZTVEkifX0.a5_nfMVr7Qe1SW0ZL3u6oQRm5NUCYUSfixDAJOUFN3XUfECBZ6E8fm8xjeSfdOytgRidTz0CTlIRjzPQo82dmQ"
  853. ap_netaccesskey = "30770201010420f6531d17f29dfab655b7c9e923478d5a345164c489aadd44a3519c3e9dcc792da00a06082a8648ce3d030107a14403420004d3cab13525c6e15ce0056a5c506309839b37a2520d4d19444f98438ba0c972f751a85a5c0cc911940131786d4c1c9879893d9086fdf4fd3b43f32aa125154932"
  854. sta_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiZWMzR3NqQ3lQMzVBUUZOQUJJdEltQnN4WXVyMGJZX1dES1lfSE9zUGdjNCIsInkiOiJTRS1HVllkdWVnTFhLMU1TQXZNMEx2QWdLREpTNWoyQVhCbE9PMTdUSTRBIn19.PDK9zsGlK-e1pEOmNxVeJfCS8pNeay6ckIS1TXCQsR64AR-9wFPCNVjqOxWvVKltehyMFqVAtOcv0IrjtMJFqQ"
  855. sta_netaccesskey = "30770201010420bc33380c26fd2168b69cd8242ed1df07ba89aa4813f8d4e8523de6ca3f8dd28ba00a06082a8648ce3d030107a1440342000479cdc6b230b23f7e40405340048b48981b3162eaf46d8fd60ca63f1ceb0f81ce484f8655876e7a02d72b531202f3342ef020283252e63d805c194e3b5ed32380"
  856. params = { "ssid": "dpp",
  857. "wpa": "2",
  858. "wpa_key_mgmt": "DPP",
  859. "ieee80211w": "2",
  860. "rsn_pairwise": "CCMP",
  861. "dpp_connector": ap_connector,
  862. "dpp_csign": csign,
  863. "dpp_netaccesskey": ap_netaccesskey }
  864. try:
  865. hapd = hostapd.add_ap(apdev[0], params)
  866. except:
  867. raise HwsimSkip("DPP not supported")
  868. id = dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412",
  869. ieee80211w="2",
  870. dpp_csign=csign,
  871. dpp_connector=sta_connector,
  872. dpp_netaccesskey=sta_netaccesskey)
  873. val = dev[0].get_status_field("key_mgmt")
  874. if val != "DPP":
  875. raise Exception("Unexpected key_mgmt: " + val)
  876. def test_dpp_ap_config(dev, apdev):
  877. """DPP and AP configuration"""
  878. run_dpp_ap_config(dev, apdev)
  879. def test_dpp_ap_config_p256_p256(dev, apdev):
  880. """DPP and AP configuration (P-256 + P-256)"""
  881. run_dpp_ap_config(dev, apdev, curve="P-256", conf_curve="P-256")
  882. def test_dpp_ap_config_p256_p384(dev, apdev):
  883. """DPP and AP configuration (P-256 + P-384)"""
  884. run_dpp_ap_config(dev, apdev, curve="P-256", conf_curve="P-384")
  885. def test_dpp_ap_config_p256_p521(dev, apdev):
  886. """DPP and AP configuration (P-256 + P-521)"""
  887. run_dpp_ap_config(dev, apdev, curve="P-256", conf_curve="P-521")
  888. def test_dpp_ap_config_p384_p256(dev, apdev):
  889. """DPP and AP configuration (P-384 + P-256)"""
  890. run_dpp_ap_config(dev, apdev, curve="P-384", conf_curve="P-256")
  891. def test_dpp_ap_config_p384_p384(dev, apdev):
  892. """DPP and AP configuration (P-384 + P-384)"""
  893. run_dpp_ap_config(dev, apdev, curve="P-384", conf_curve="P-384")
  894. def test_dpp_ap_config_p384_p521(dev, apdev):
  895. """DPP and AP configuration (P-384 + P-521)"""
  896. run_dpp_ap_config(dev, apdev, curve="P-384", conf_curve="P-521")
  897. def test_dpp_ap_config_p521_p256(dev, apdev):
  898. """DPP and AP configuration (P-521 + P-256)"""
  899. run_dpp_ap_config(dev, apdev, curve="P-521", conf_curve="P-256")
  900. def test_dpp_ap_config_p521_p384(dev, apdev):
  901. """DPP and AP configuration (P-521 + P-384)"""
  902. run_dpp_ap_config(dev, apdev, curve="P-521", conf_curve="P-384")
  903. def test_dpp_ap_config_p521_p521(dev, apdev):
  904. """DPP and AP configuration (P-521 + P-521)"""
  905. run_dpp_ap_config(dev, apdev, curve="P-521", conf_curve="P-521")
  906. def update_hapd_config(hapd):
  907. ev = hapd.wait_event(["DPP-CONFOBJ-SSID"], timeout=1)
  908. if ev is None:
  909. raise Exception("SSID not reported (AP)")
  910. ssid = ev.split(' ')[1]
  911. ev = hapd.wait_event(["DPP-CONNECTOR"], timeout=1)
  912. if ev is None:
  913. raise Exception("Connector not reported (AP)")
  914. connector = ev.split(' ')[1]
  915. ev = hapd.wait_event(["DPP-C-SIGN-KEY"], timeout=1)
  916. if ev is None:
  917. raise Exception("C-sign-key not reported (AP)")
  918. p = ev.split(' ')
  919. csign = p[1]
  920. ev = hapd.wait_event(["DPP-NET-ACCESS-KEY"], timeout=1)
  921. if ev is None:
  922. raise Exception("netAccessKey not reported (AP)")
  923. p = ev.split(' ')
  924. net_access_key = p[1]
  925. net_access_key_expiry = p[2] if len(p) > 2 else None
  926. logger.info("Update AP configuration to use key_mgmt=DPP")
  927. hapd.disable()
  928. hapd.set("ssid", ssid)
  929. hapd.set("wpa", "2")
  930. hapd.set("wpa_key_mgmt", "DPP")
  931. hapd.set("ieee80211w", "2")
  932. hapd.set("rsn_pairwise", "CCMP")
  933. hapd.set("dpp_connector", connector)
  934. hapd.set("dpp_csign", csign)
  935. hapd.set("dpp_netaccesskey", net_access_key)
  936. if net_access_key_expiry:
  937. hapd.set("dpp_netaccesskey_expiry", net_access_key_expiry)
  938. hapd.enable()
  939. def run_dpp_ap_config(dev, apdev, curve=None, conf_curve=None):
  940. check_dpp_capab(dev[0])
  941. check_dpp_capab(dev[1])
  942. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" })
  943. check_dpp_capab(hapd)
  944. addr = hapd.own_addr().replace(':', '')
  945. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  946. if curve:
  947. cmd += " curve=" + curve
  948. res = hapd.request(cmd)
  949. if "FAIL" in res:
  950. raise Exception("Failed to generate bootstrapping info")
  951. id_h = int(res)
  952. uri = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id_h)
  953. cmd = "DPP_CONFIGURATOR_ADD"
  954. if conf_curve:
  955. cmd += " curve=" + conf_curve
  956. res = dev[0].request(cmd);
  957. if "FAIL" in res:
  958. raise Exception("Failed to add configurator")
  959. conf_id = int(res)
  960. res = dev[0].request("DPP_QR_CODE " + uri)
  961. if "FAIL" in res:
  962. raise Exception("Failed to parse QR Code URI")
  963. id = int(res)
  964. cmd = "DPP_AUTH_INIT peer=%d conf=ap-dpp configurator=%d" % (id, conf_id)
  965. if "OK" not in dev[0].request(cmd):
  966. raise Exception("Failed to initiate DPP Authentication")
  967. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  968. if ev is None:
  969. raise Exception("DPP authentication did not succeed (Responder)")
  970. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  971. if ev is None:
  972. raise Exception("DPP authentication did not succeed (Initiator)")
  973. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  974. if ev is None:
  975. raise Exception("DPP configuration not completed (Configurator)")
  976. ev = hapd.wait_event(["DPP-CONF-RECEIVED", "DPP-CONF-FAILED"], timeout=5)
  977. if ev is None:
  978. raise Exception("DPP configuration not completed (Enrollee)")
  979. if "DPP-CONF-FAILED" in ev:
  980. raise Exception("DPP configuration failed")
  981. update_hapd_config(hapd)
  982. addr = dev[1].own_addr().replace(':', '')
  983. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  984. if curve:
  985. cmd += " curve=" + curve
  986. res = dev[1].request(cmd)
  987. if "FAIL" in res:
  988. raise Exception("Failed to generate bootstrapping info")
  989. id1 = int(res)
  990. uri1 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1)
  991. res = dev[0].request("DPP_QR_CODE " + uri1)
  992. if "FAIL" in res:
  993. raise Exception("Failed to parse QR Code URI")
  994. id0b = int(res)
  995. cmd = "DPP_LISTEN 2412"
  996. if "OK" not in dev[1].request(cmd):
  997. raise Exception("Failed to start listen operation")
  998. cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id0b, conf_id)
  999. if "OK" not in dev[0].request(cmd):
  1000. raise Exception("Failed to initiate DPP Authentication")
  1001. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1002. if ev is None:
  1003. raise Exception("DPP authentication did not succeed (Responder)")
  1004. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1005. if ev is None:
  1006. raise Exception("DPP authentication did not succeed (Initiator)")
  1007. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1008. if ev is None:
  1009. raise Exception("DPP configuration not completed (Configurator)")
  1010. ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1011. if ev is None:
  1012. raise Exception("DPP configuration not completed (Enrollee)")
  1013. dev[1].request("DPP_STOP_LISTEN")
  1014. ev = dev[1].wait_event(["DPP-CONFOBJ-SSID"], timeout=1)
  1015. if ev is None:
  1016. raise Exception("SSID not reported")
  1017. ssid = ev.split(' ')[1]
  1018. ev = dev[1].wait_event(["DPP-CONNECTOR"], timeout=1)
  1019. if ev is None:
  1020. raise Exception("Connector not reported")
  1021. connector = ev.split(' ')[1]
  1022. ev = dev[1].wait_event(["DPP-C-SIGN-KEY"], timeout=1)
  1023. if ev is None:
  1024. raise Exception("C-sign-key not reported")
  1025. p = ev.split(' ')
  1026. csign = p[1]
  1027. ev = dev[1].wait_event(["DPP-NET-ACCESS-KEY"], timeout=1)
  1028. if ev is None:
  1029. raise Exception("netAccessKey not reported")
  1030. p = ev.split(' ')
  1031. net_access_key = p[1]
  1032. net_access_key_expiry = p[2] if len(p) > 2 else None
  1033. dev[1].dump_monitor()
  1034. id = dev[1].connect(ssid, key_mgmt="DPP", ieee80211w="2", scan_freq="2412",
  1035. only_add_network=True)
  1036. dev[1].set_network_quoted(id, "dpp_connector", connector)
  1037. dev[1].set_network(id, "dpp_csign", csign)
  1038. dev[1].set_network(id, "dpp_netaccesskey", net_access_key)
  1039. if net_access_key_expiry:
  1040. dev[1].set_network(id, "dpp_netaccess_expiry", net_access_key_expiry)
  1041. logger.info("Check data connection")
  1042. dev[1].select_network(id, freq="2412")
  1043. dev[1].wait_connected()
  1044. def test_dpp_auto_connect_1(dev, apdev):
  1045. """DPP and auto connect (1)"""
  1046. try:
  1047. run_dpp_auto_connect(dev, apdev, 1)
  1048. finally:
  1049. dev[0].set("dpp_config_processing", "0")
  1050. def test_dpp_auto_connect_2(dev, apdev):
  1051. """DPP and auto connect (2)"""
  1052. try:
  1053. run_dpp_auto_connect(dev, apdev, 2)
  1054. finally:
  1055. dev[0].set("dpp_config_processing", "0")
  1056. def test_dpp_auto_connect_2_connect_cmd(dev, apdev):
  1057. """DPP and auto connect (2) using connect_cmd"""
  1058. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  1059. wpas.interface_add("wlan5", drv_params="force_connect_cmd=1")
  1060. dev_new = [ wpas, dev[1] ]
  1061. try:
  1062. run_dpp_auto_connect(dev_new, apdev, 2)
  1063. finally:
  1064. wpas.set("dpp_config_processing", "0")
  1065. def run_dpp_auto_connect(dev, apdev, processing):
  1066. check_dpp_capab(dev[0])
  1067. check_dpp_capab(dev[1])
  1068. csign = "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
  1069. csign_pub = "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
  1070. ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg"
  1071. ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b"
  1072. params = { "ssid": "test",
  1073. "wpa": "2",
  1074. "wpa_key_mgmt": "DPP",
  1075. "ieee80211w": "2",
  1076. "rsn_pairwise": "CCMP",
  1077. "dpp_connector": ap_connector,
  1078. "dpp_csign": csign_pub,
  1079. "dpp_netaccesskey": ap_netaccesskey }
  1080. try:
  1081. hapd = hostapd.add_ap(apdev[0], params)
  1082. except:
  1083. raise HwsimSkip("DPP not supported")
  1084. cmd = "DPP_CONFIGURATOR_ADD key=" + csign
  1085. res = dev[1].request(cmd)
  1086. if "FAIL" in res:
  1087. raise Exception("DPP_CONFIGURATOR_ADD failed")
  1088. conf_id = int(res)
  1089. dev[0].set("dpp_config_processing", str(processing))
  1090. addr = dev[0].own_addr().replace(':', '')
  1091. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1092. res = dev[0].request(cmd)
  1093. if "FAIL" in res:
  1094. raise Exception("Failed to generate bootstrapping info")
  1095. id0 = int(res)
  1096. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1097. res = dev[1].request("DPP_QR_CODE " + uri0)
  1098. if "FAIL" in res:
  1099. raise Exception("Failed to parse QR Code URI")
  1100. id1 = int(res)
  1101. cmd = "DPP_LISTEN 2412"
  1102. if "OK" not in dev[0].request(cmd):
  1103. raise Exception("Failed to start listen operation")
  1104. cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id1, conf_id)
  1105. if "OK" not in dev[1].request(cmd):
  1106. raise Exception("Failed to initiate DPP Authentication")
  1107. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=10)
  1108. if ev is None:
  1109. raise Exception("DPP configuration not completed (Configurator)")
  1110. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=2)
  1111. if ev is None:
  1112. raise Exception("DPP configuration not completed (Enrollee)")
  1113. ev = dev[0].wait_event(["DPP-NETWORK-ID"], timeout=1)
  1114. if ev is None:
  1115. raise Exception("DPP network profile not generated")
  1116. id = ev.split(' ')[1]
  1117. if processing == 1:
  1118. dev[0].select_network(id, freq=2412)
  1119. dev[0].wait_connected()
  1120. hwsim_utils.test_connectivity(dev[0], hapd)
  1121. def test_dpp_auto_connect_legacy(dev, apdev):
  1122. """DPP and auto connect (legacy)"""
  1123. try:
  1124. run_dpp_auto_connect_legacy(dev, apdev)
  1125. finally:
  1126. dev[0].set("dpp_config_processing", "0")
  1127. def run_dpp_auto_connect_legacy(dev, apdev):
  1128. check_dpp_capab(dev[0])
  1129. check_dpp_capab(dev[1])
  1130. params = hostapd.wpa2_params(ssid="dpp-legacy",
  1131. passphrase="secret passphrase")
  1132. hapd = hostapd.add_ap(apdev[0], params)
  1133. dev[0].set("dpp_config_processing", "2")
  1134. addr = dev[0].own_addr().replace(':', '')
  1135. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1136. res = dev[0].request(cmd)
  1137. if "FAIL" in res:
  1138. raise Exception("Failed to generate bootstrapping info")
  1139. id0 = int(res)
  1140. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1141. res = dev[1].request("DPP_QR_CODE " + uri0)
  1142. if "FAIL" in res:
  1143. raise Exception("Failed to parse QR Code URI")
  1144. id1 = int(res)
  1145. cmd = "DPP_LISTEN 2412"
  1146. if "OK" not in dev[0].request(cmd):
  1147. raise Exception("Failed to start listen operation")
  1148. cmd = "DPP_AUTH_INIT peer=%d conf=sta-psk ssid=%s pass=%s" % (id1, "dpp-legacy".encode("hex"), "secret passphrase".encode("hex"))
  1149. if "OK" not in dev[1].request(cmd):
  1150. raise Exception("Failed to initiate DPP Authentication")
  1151. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=10)
  1152. if ev is None:
  1153. raise Exception("DPP configuration not completed (Configurator)")
  1154. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=2)
  1155. if ev is None:
  1156. raise Exception("DPP configuration not completed (Enrollee)")
  1157. ev = dev[0].wait_event(["DPP-NETWORK-ID"], timeout=1)
  1158. if ev is None:
  1159. raise Exception("DPP network profile not generated")
  1160. id = ev.split(' ')[1]
  1161. dev[0].wait_connected()
  1162. def test_dpp_auto_connect_legacy_pmf_required(dev, apdev):
  1163. """DPP and auto connect (legacy, PMF required)"""
  1164. try:
  1165. run_dpp_auto_connect_legacy_pmf_required(dev, apdev)
  1166. finally:
  1167. dev[0].set("dpp_config_processing", "0")
  1168. def run_dpp_auto_connect_legacy_pmf_required(dev, apdev):
  1169. check_dpp_capab(dev[0])
  1170. check_dpp_capab(dev[1])
  1171. params = hostapd.wpa2_params(ssid="dpp-legacy",
  1172. passphrase="secret passphrase")
  1173. params['wpa_key_mgmt'] = "WPA-PSK-SHA256"
  1174. params['ieee80211w'] = "2"
  1175. hapd = hostapd.add_ap(apdev[0], params)
  1176. dev[0].set("dpp_config_processing", "2")
  1177. addr = dev[0].own_addr().replace(':', '')
  1178. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1179. res = dev[0].request(cmd)
  1180. if "FAIL" in res:
  1181. raise Exception("Failed to generate bootstrapping info")
  1182. id0 = int(res)
  1183. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1184. res = dev[1].request("DPP_QR_CODE " + uri0)
  1185. if "FAIL" in res:
  1186. raise Exception("Failed to parse QR Code URI")
  1187. id1 = int(res)
  1188. cmd = "DPP_LISTEN 2412"
  1189. if "OK" not in dev[0].request(cmd):
  1190. raise Exception("Failed to start listen operation")
  1191. cmd = "DPP_AUTH_INIT peer=%d conf=sta-psk ssid=%s pass=%s" % (id1, "dpp-legacy".encode("hex"), "secret passphrase".encode("hex"))
  1192. if "OK" not in dev[1].request(cmd):
  1193. raise Exception("Failed to initiate DPP Authentication")
  1194. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=10)
  1195. if ev is None:
  1196. raise Exception("DPP configuration not completed (Configurator)")
  1197. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=2)
  1198. if ev is None:
  1199. raise Exception("DPP configuration not completed (Enrollee)")
  1200. ev = dev[0].wait_event(["DPP-NETWORK-ID"], timeout=1)
  1201. if ev is None:
  1202. raise Exception("DPP network profile not generated")
  1203. id = ev.split(' ')[1]
  1204. dev[0].wait_connected()
  1205. def test_dpp_qr_code_auth_responder_configurator(dev, apdev):
  1206. """DPP QR Code and responder as the configurator"""
  1207. check_dpp_capab(dev[0])
  1208. check_dpp_capab(dev[1])
  1209. cmd = "DPP_CONFIGURATOR_ADD"
  1210. res = dev[0].request(cmd);
  1211. if "FAIL" in res:
  1212. raise Exception("Failed to add configurator")
  1213. conf_id = int(res)
  1214. addr = dev[0].own_addr().replace(':', '')
  1215. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1216. res = dev[0].request(cmd)
  1217. if "FAIL" in res:
  1218. raise Exception("Failed to generate bootstrapping info")
  1219. id0 = int(res)
  1220. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1221. res = dev[1].request("DPP_QR_CODE " + uri0)
  1222. if "FAIL" in res:
  1223. raise Exception("Failed to parse QR Code URI")
  1224. id1 = int(res)
  1225. dev[0].set("dpp_configurator_params", " conf=sta-dpp configurator=%d" % conf_id);
  1226. cmd = "DPP_LISTEN 2412 role=configurator"
  1227. if "OK" not in dev[0].request(cmd):
  1228. raise Exception("Failed to start listen operation")
  1229. cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % id1
  1230. if "OK" not in dev[1].request(cmd):
  1231. raise Exception("Failed to initiate DPP Authentication")
  1232. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1233. if ev is None:
  1234. raise Exception("DPP authentication did not succeed (Responder)")
  1235. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1236. if ev is None:
  1237. raise Exception("DPP authentication did not succeed (Initiator)")
  1238. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1239. if ev is None:
  1240. raise Exception("DPP configuration not completed (Configurator)")
  1241. ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1242. if ev is None:
  1243. raise Exception("DPP configuration not completed (Enrollee)")
  1244. dev[0].request("DPP_STOP_LISTEN")
  1245. dev[0].dump_monitor()
  1246. dev[1].dump_monitor()
  1247. def test_dpp_qr_code_hostapd_init(dev, apdev):
  1248. """DPP QR Code and hostapd as initiator"""
  1249. check_dpp_capab(dev[0])
  1250. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1251. "channel": "6" })
  1252. check_dpp_capab(hapd)
  1253. cmd = "DPP_CONFIGURATOR_ADD"
  1254. res = dev[0].request(cmd);
  1255. if "FAIL" in res:
  1256. raise Exception("Failed to add configurator")
  1257. conf_id = int(res)
  1258. addr = dev[0].own_addr().replace(':', '')
  1259. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
  1260. res = dev[0].request(cmd)
  1261. if "FAIL" in res:
  1262. raise Exception("Failed to generate bootstrapping info")
  1263. id0 = int(res)
  1264. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1265. dev[0].set("dpp_configurator_params",
  1266. " conf=ap-dpp configurator=%d" % conf_id);
  1267. cmd = "DPP_LISTEN 2437 role=configurator"
  1268. if "OK" not in dev[0].request(cmd):
  1269. raise Exception("Failed to start listen operation")
  1270. res = hapd.request("DPP_QR_CODE " + uri0)
  1271. if "FAIL" in res:
  1272. raise Exception("Failed to parse QR Code URI")
  1273. id1 = int(res)
  1274. cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % id1
  1275. if "OK" not in hapd.request(cmd):
  1276. raise Exception("Failed to initiate DPP Authentication")
  1277. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1278. if ev is None:
  1279. raise Exception("DPP authentication did not succeed (Responder)")
  1280. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1281. if ev is None:
  1282. raise Exception("DPP authentication did not succeed (Initiator)")
  1283. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1284. if ev is None:
  1285. raise Exception("DPP configuration not completed (Configurator)")
  1286. ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1287. if ev is None:
  1288. raise Exception("DPP configuration not completed (Enrollee)")
  1289. dev[0].request("DPP_STOP_LISTEN")
  1290. dev[0].dump_monitor()
  1291. def test_dpp_pkex(dev, apdev):
  1292. """DPP and PKEX"""
  1293. run_dpp_pkex(dev, apdev)
  1294. def test_dpp_pkex_p256(dev, apdev):
  1295. """DPP and PKEX (P-256)"""
  1296. run_dpp_pkex(dev, apdev, "P-256")
  1297. def test_dpp_pkex_p384(dev, apdev):
  1298. """DPP and PKEX (P-384)"""
  1299. run_dpp_pkex(dev, apdev, "P-384")
  1300. def test_dpp_pkex_p521(dev, apdev):
  1301. """DPP and PKEX (P-521)"""
  1302. run_dpp_pkex(dev, apdev, "P-521")
  1303. def test_dpp_pkex_bp256(dev, apdev):
  1304. """DPP and PKEX (BP-256)"""
  1305. run_dpp_pkex(dev, apdev, "brainpoolP256r1")
  1306. def test_dpp_pkex_bp384(dev, apdev):
  1307. """DPP and PKEX (BP-384)"""
  1308. run_dpp_pkex(dev, apdev, "brainpoolP384r1")
  1309. def test_dpp_pkex_bp512(dev, apdev):
  1310. """DPP and PKEX (BP-512)"""
  1311. run_dpp_pkex(dev, apdev, "brainpoolP512r1")
  1312. def test_dpp_pkex_config(dev, apdev):
  1313. """DPP and PKEX with initiator as the configurator"""
  1314. check_dpp_capab(dev[1])
  1315. cmd = "DPP_CONFIGURATOR_ADD"
  1316. res = dev[1].request(cmd);
  1317. if "FAIL" in res:
  1318. raise Exception("Failed to add configurator")
  1319. conf_id = int(res)
  1320. run_dpp_pkex(dev, apdev,
  1321. init_extra="conf=sta-dpp configurator=%d" % (conf_id),
  1322. check_config=True)
  1323. def run_dpp_pkex(dev, apdev, curve=None, init_extra="", check_config=False):
  1324. check_dpp_capab(dev[0])
  1325. check_dpp_capab(dev[1])
  1326. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1327. if curve:
  1328. cmd += " curve=" + curve
  1329. res = dev[0].request(cmd)
  1330. if "FAIL" in res:
  1331. raise Exception("Failed to generate bootstrapping info")
  1332. id0 = int(res)
  1333. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1334. if curve:
  1335. cmd += " curve=" + curve
  1336. res = dev[1].request(cmd)
  1337. if "FAIL" in res:
  1338. raise Exception("Failed to generate bootstrapping info")
  1339. id1 = int(res)
  1340. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1341. res = dev[0].request(cmd)
  1342. if "FAIL" in res:
  1343. raise Exception("Failed to set PKEX data (responder)")
  1344. cmd = "DPP_LISTEN 2437"
  1345. if "OK" not in dev[0].request(cmd):
  1346. raise Exception("Failed to start listen operation")
  1347. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 %s code=secret" % (id1, init_extra)
  1348. res = dev[1].request(cmd)
  1349. if "FAIL" in res:
  1350. raise Exception("Failed to set PKEX data (initiator)")
  1351. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1352. if ev is None:
  1353. raise Exception("DPP authentication did not succeed (Initiator)")
  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. if check_config:
  1358. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=5)
  1359. if ev is None:
  1360. raise Exception("DPP configuration not completed (Configurator)")
  1361. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1362. if ev is None:
  1363. raise Exception("DPP configuration not completed (Enrollee)")
  1364. def test_dpp_pkex_code_mismatch(dev, apdev):
  1365. """DPP and PKEX with mismatching code"""
  1366. check_dpp_capab(dev[0])
  1367. check_dpp_capab(dev[1])
  1368. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1369. res = dev[0].request(cmd)
  1370. if "FAIL" in res:
  1371. raise Exception("Failed to generate bootstrapping info")
  1372. id0 = int(res)
  1373. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1374. res = dev[1].request(cmd)
  1375. if "FAIL" in res:
  1376. raise Exception("Failed to generate bootstrapping info")
  1377. id1 = int(res)
  1378. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1379. res = dev[0].request(cmd)
  1380. if "FAIL" in res:
  1381. raise Exception("Failed to set PKEX data (responder)")
  1382. cmd = "DPP_LISTEN 2437"
  1383. if "OK" not in dev[0].request(cmd):
  1384. raise Exception("Failed to start listen operation")
  1385. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 code=unknown" % id1
  1386. res = dev[1].request(cmd)
  1387. if "FAIL" in res:
  1388. raise Exception("Failed to set PKEX data (initiator)")
  1389. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  1390. if ev is None:
  1391. raise Exception("Failure not reported")
  1392. if "possible PKEX code mismatch" not in ev:
  1393. raise Exception("Unexpected result: " + ev)
  1394. dev[0].dump_monitor()
  1395. dev[1].dump_monitor()
  1396. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 code=secret" % id1
  1397. res = dev[1].request(cmd)
  1398. if "FAIL" in res:
  1399. raise Exception("Failed to set PKEX data (initiator, retry)")
  1400. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1401. if ev is None:
  1402. raise Exception("DPP authentication did not succeed (Initiator, retry)")
  1403. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1404. if ev is None:
  1405. raise Exception("DPP authentication did not succeed (Responder, retry)")
  1406. def test_dpp_pkex_code_mismatch_limit(dev, apdev):
  1407. """DPP and PKEX with mismatching code limit"""
  1408. check_dpp_capab(dev[0])
  1409. check_dpp_capab(dev[1])
  1410. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1411. res = dev[0].request(cmd)
  1412. if "FAIL" in res:
  1413. raise Exception("Failed to generate bootstrapping info")
  1414. id0 = int(res)
  1415. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1416. res = dev[1].request(cmd)
  1417. if "FAIL" in res:
  1418. raise Exception("Failed to generate bootstrapping info")
  1419. id1 = int(res)
  1420. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1421. res = dev[0].request(cmd)
  1422. if "FAIL" in res:
  1423. raise Exception("Failed to set PKEX data (responder)")
  1424. cmd = "DPP_LISTEN 2437"
  1425. if "OK" not in dev[0].request(cmd):
  1426. raise Exception("Failed to start listen operation")
  1427. for i in range(5):
  1428. dev[0].dump_monitor()
  1429. dev[1].dump_monitor()
  1430. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 code=unknown" % id1
  1431. res = dev[1].request(cmd)
  1432. if "FAIL" in res:
  1433. raise Exception("Failed to set PKEX data (initiator)")
  1434. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  1435. if ev is None:
  1436. raise Exception("Failure not reported")
  1437. if "possible PKEX code mismatch" not in ev:
  1438. raise Exception("Unexpected result: " + ev)
  1439. ev = dev[0].wait_event(["DPP-PKEX-T-LIMIT"], timeout=1)
  1440. if ev is None:
  1441. raise Exception("PKEX t limit not reported")
  1442. def test_dpp_pkex_curve_mismatch(dev, apdev):
  1443. """DPP and PKEX with mismatching curve"""
  1444. check_dpp_capab(dev[0])
  1445. check_dpp_capab(dev[1])
  1446. cmd = "DPP_BOOTSTRAP_GEN type=pkex curve=P-256"
  1447. res = dev[0].request(cmd)
  1448. if "FAIL" in res:
  1449. raise Exception("Failed to generate bootstrapping info")
  1450. id0 = int(res)
  1451. cmd = "DPP_BOOTSTRAP_GEN type=pkex curve=P-384"
  1452. res = dev[1].request(cmd)
  1453. if "FAIL" in res:
  1454. raise Exception("Failed to generate bootstrapping info")
  1455. id1 = int(res)
  1456. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1457. res = dev[0].request(cmd)
  1458. if "FAIL" in res:
  1459. raise Exception("Failed to set PKEX data (responder)")
  1460. cmd = "DPP_LISTEN 2437"
  1461. if "OK" not in dev[0].request(cmd):
  1462. raise Exception("Failed to start listen operation")
  1463. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 code=secret" % id1
  1464. res = dev[1].request(cmd)
  1465. if "FAIL" in res:
  1466. raise Exception("Failed to set PKEX data (initiator)")
  1467. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  1468. if ev is None:
  1469. raise Exception("Failure not reported (dev 0)")
  1470. if "Mismatching PKEX curve: peer=20 own=19" not in ev:
  1471. raise Exception("Unexpected result: " + ev)
  1472. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  1473. if ev is None:
  1474. raise Exception("Failure not reported (dev 1)")
  1475. if "Peer indicated mismatching PKEX group - proposed 19" not in ev:
  1476. raise Exception("Unexpected result: " + ev)
  1477. def test_dpp_pkex_config2(dev, apdev):
  1478. """DPP and PKEX with responder as the configurator"""
  1479. check_dpp_capab(dev[0])
  1480. cmd = "DPP_CONFIGURATOR_ADD"
  1481. res = dev[0].request(cmd);
  1482. if "FAIL" in res:
  1483. raise Exception("Failed to add configurator")
  1484. conf_id = int(res)
  1485. dev[0].set("dpp_configurator_params",
  1486. " conf=sta-dpp configurator=%d" % conf_id);
  1487. run_dpp_pkex2(dev, apdev)
  1488. def run_dpp_pkex2(dev, apdev, curve=None, init_extra=""):
  1489. check_dpp_capab(dev[0])
  1490. check_dpp_capab(dev[1])
  1491. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1492. if curve:
  1493. cmd += " curve=" + curve
  1494. res = dev[0].request(cmd)
  1495. if "FAIL" in res:
  1496. raise Exception("Failed to generate bootstrapping info")
  1497. id0 = int(res)
  1498. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1499. if curve:
  1500. cmd += " curve=" + curve
  1501. res = dev[1].request(cmd)
  1502. if "FAIL" in res:
  1503. raise Exception("Failed to generate bootstrapping info")
  1504. id1 = int(res)
  1505. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1506. res = dev[0].request(cmd)
  1507. if "FAIL" in res:
  1508. raise Exception("Failed to set PKEX data (responder)")
  1509. cmd = "DPP_LISTEN 2437 role=configurator"
  1510. if "OK" not in dev[0].request(cmd):
  1511. raise Exception("Failed to start listen operation")
  1512. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 role=enrollee %s code=secret" % (id1, init_extra)
  1513. res = dev[1].request(cmd)
  1514. if "FAIL" in res:
  1515. raise Exception("Failed to set PKEX data (initiator)")
  1516. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1517. if ev is None:
  1518. raise Exception("DPP authentication did not succeed (Initiator)")
  1519. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1520. if ev is None:
  1521. raise Exception("DPP authentication did not succeed (Responder)")
  1522. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1523. if ev is None:
  1524. raise Exception("DPP configuration not completed (Configurator)")
  1525. ev = dev[1].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1526. if ev is None:
  1527. raise Exception("DPP configuration not completed (Enrollee)")
  1528. def test_dpp_pkex_hostapd_responder(dev, apdev):
  1529. """DPP PKEX with hostapd as responder"""
  1530. check_dpp_capab(dev[0])
  1531. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1532. "channel": "6" })
  1533. check_dpp_capab(hapd)
  1534. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1535. res = hapd.request(cmd)
  1536. if "FAIL" in res:
  1537. raise Exception("Failed to generate bootstrapping info (hostapd)")
  1538. id_h = int(res)
  1539. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id_h)
  1540. res = hapd.request(cmd)
  1541. if "FAIL" in res:
  1542. raise Exception("Failed to set PKEX data (responder/hostapd)")
  1543. cmd = "DPP_CONFIGURATOR_ADD"
  1544. res = dev[0].request(cmd);
  1545. if "FAIL" in res:
  1546. raise Exception("Failed to add configurator")
  1547. conf_id = int(res)
  1548. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1549. res = dev[0].request(cmd)
  1550. if "FAIL" in res:
  1551. raise Exception("Failed to generate bootstrapping info (wpa_supplicant)")
  1552. id0 = int(res)
  1553. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 conf=ap-dpp configurator=%d code=secret" % (id0, conf_id)
  1554. res = dev[0].request(cmd)
  1555. if "FAIL" in res:
  1556. raise Exception("Failed to set PKEX data (initiator/wpa_supplicant)")
  1557. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1558. if ev is None:
  1559. raise Exception("DPP authentication did not succeed (Initiator)")
  1560. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1561. if ev is None:
  1562. raise Exception("DPP authentication did not succeed (Responder)")
  1563. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1564. if ev is None:
  1565. raise Exception("DPP configuration not completed (Configurator)")
  1566. ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1567. if ev is None:
  1568. raise Exception("DPP configuration not completed (Enrollee)")
  1569. dev[0].request("DPP_STOP_LISTEN")
  1570. dev[0].dump_monitor()
  1571. def test_dpp_pkex_hostapd_initiator(dev, apdev):
  1572. """DPP PKEX with hostapd as initiator"""
  1573. check_dpp_capab(dev[0])
  1574. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1575. "channel": "6" })
  1576. check_dpp_capab(hapd)
  1577. cmd = "DPP_CONFIGURATOR_ADD"
  1578. res = dev[0].request(cmd);
  1579. if "FAIL" in res:
  1580. raise Exception("Failed to add configurator")
  1581. conf_id = int(res)
  1582. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1583. res = dev[0].request(cmd)
  1584. if "FAIL" in res:
  1585. raise Exception("Failed to generate bootstrapping info (wpa_supplicant)")
  1586. id0 = int(res)
  1587. dev[0].set("dpp_configurator_params",
  1588. " conf=ap-dpp configurator=%d" % conf_id);
  1589. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  1590. res = dev[0].request(cmd)
  1591. if "FAIL" in res:
  1592. raise Exception("Failed to set PKEX data (responder/wpa_supplicant)")
  1593. cmd = "DPP_LISTEN 2437 role=configurator"
  1594. if "OK" not in dev[0].request(cmd):
  1595. raise Exception("Failed to start listen operation")
  1596. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  1597. res = hapd.request(cmd)
  1598. if "FAIL" in res:
  1599. raise Exception("Failed to generate bootstrapping info (hostapd)")
  1600. id_h = int(res)
  1601. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 role=enrollee code=secret" % (id_h)
  1602. res = hapd.request(cmd)
  1603. if "FAIL" in res:
  1604. raise Exception("Failed to set PKEX data (initiator/hostapd)")
  1605. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1606. if ev is None:
  1607. raise Exception("DPP authentication did not succeed (Initiator)")
  1608. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1609. if ev is None:
  1610. raise Exception("DPP authentication did not succeed (Responder)")
  1611. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1612. if ev is None:
  1613. raise Exception("DPP configuration not completed (Configurator)")
  1614. ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1615. if ev is None:
  1616. raise Exception("DPP configuration not completed (Enrollee)")
  1617. dev[0].request("DPP_STOP_LISTEN")
  1618. dev[0].dump_monitor()
  1619. def test_dpp_hostapd_configurator(dev, apdev):
  1620. """DPP with hostapd as configurator/initiator"""
  1621. check_dpp_capab(dev[0])
  1622. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1623. "channel": "1" })
  1624. check_dpp_capab(hapd)
  1625. cmd = "DPP_CONFIGURATOR_ADD"
  1626. res = hapd.request(cmd);
  1627. if "FAIL" in res:
  1628. raise Exception("Failed to add configurator")
  1629. conf_id = int(res)
  1630. addr = dev[0].own_addr().replace(':', '')
  1631. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1632. res = dev[0].request(cmd)
  1633. if "FAIL" in res:
  1634. raise Exception("Failed to generate bootstrapping info")
  1635. id0 = int(res)
  1636. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1637. res = hapd.request("DPP_QR_CODE " + uri0)
  1638. if "FAIL" in res:
  1639. raise Exception("Failed to parse QR Code URI")
  1640. id1 = int(res)
  1641. res = hapd.request("DPP_BOOTSTRAP_INFO %d" % id0)
  1642. if "FAIL" in res:
  1643. raise Exception("DPP_BOOTSTRAP_INFO failed")
  1644. if "type=QRCODE" not in res:
  1645. raise Exception("DPP_BOOTSTRAP_INFO did not report correct type")
  1646. if "mac_addr=" + dev[0].own_addr() not in res:
  1647. raise Exception("DPP_BOOTSTRAP_INFO did not report correct mac_addr")
  1648. cmd = "DPP_LISTEN 2412"
  1649. if "OK" not in dev[0].request(cmd):
  1650. raise Exception("Failed to start listen operation")
  1651. cmd = "DPP_AUTH_INIT peer=%d configurator=%d conf=sta-dpp" % (id1, conf_id)
  1652. if "OK" not in hapd.request(cmd):
  1653. raise Exception("Failed to initiate DPP Authentication")
  1654. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1655. if ev is None:
  1656. raise Exception("DPP authentication did not succeed (Responder)")
  1657. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1658. if ev is None:
  1659. raise Exception("DPP authentication did not succeed (Initiator)")
  1660. ev = hapd.wait_event(["DPP-CONF-SENT"], timeout=5)
  1661. if ev is None:
  1662. raise Exception("DPP configuration not completed (Configurator)")
  1663. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1664. if ev is None:
  1665. raise Exception("DPP configuration not completed (Enrollee)")
  1666. dev[0].request("DPP_STOP_LISTEN")
  1667. dev[0].dump_monitor()
  1668. def test_dpp_hostapd_configurator_responder(dev, apdev):
  1669. """DPP with hostapd as configurator/responder"""
  1670. check_dpp_capab(dev[0])
  1671. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured",
  1672. "channel": "1" })
  1673. check_dpp_capab(hapd)
  1674. cmd = "DPP_CONFIGURATOR_ADD"
  1675. res = hapd.request(cmd);
  1676. if "FAIL" in res:
  1677. raise Exception("Failed to add configurator")
  1678. conf_id = int(res)
  1679. hapd.set("dpp_configurator_params",
  1680. " conf=sta-dpp configurator=%d" % conf_id);
  1681. addr = hapd.own_addr().replace(':', '')
  1682. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1683. res = hapd.request(cmd)
  1684. if "FAIL" in res:
  1685. raise Exception("Failed to generate bootstrapping info")
  1686. id0 = int(res)
  1687. uri0 = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1688. res = dev[0].request("DPP_QR_CODE " + uri0)
  1689. if "FAIL" in res:
  1690. raise Exception("Failed to parse QR Code URI")
  1691. id1 = int(res)
  1692. cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % (id1)
  1693. if "OK" not in dev[0].request(cmd):
  1694. raise Exception("Failed to initiate DPP Authentication")
  1695. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1696. if ev is None:
  1697. raise Exception("DPP authentication did not succeed (Responder)")
  1698. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1699. if ev is None:
  1700. raise Exception("DPP authentication did not succeed (Initiator)")
  1701. ev = hapd.wait_event(["DPP-CONF-SENT"], timeout=5)
  1702. if ev is None:
  1703. raise Exception("DPP configuration not completed (Configurator)")
  1704. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1705. if ev is None:
  1706. raise Exception("DPP configuration not completed (Enrollee)")
  1707. dev[0].request("DPP_STOP_LISTEN")
  1708. dev[0].dump_monitor()
  1709. def test_dpp_own_config(dev, apdev):
  1710. """DPP configurator signing own connector"""
  1711. try:
  1712. run_dpp_own_config(dev, apdev)
  1713. finally:
  1714. dev[0].set("dpp_config_processing", "0")
  1715. def test_dpp_own_config_curve_mismatch(dev, apdev):
  1716. """DPP configurator signing own connector using mismatching curve"""
  1717. try:
  1718. run_dpp_own_config(dev, apdev, own_curve="BP-384", expect_failure=True)
  1719. finally:
  1720. dev[0].set("dpp_config_processing", "0")
  1721. def run_dpp_own_config(dev, apdev, own_curve=None, expect_failure=False):
  1722. check_dpp_capab(dev[0])
  1723. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" })
  1724. check_dpp_capab(hapd)
  1725. addr = hapd.own_addr().replace(':', '')
  1726. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1727. res = hapd.request(cmd)
  1728. if "FAIL" in res:
  1729. raise Exception("Failed to generate bootstrapping info")
  1730. id_h = int(res)
  1731. uri = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id_h)
  1732. cmd = "DPP_CONFIGURATOR_ADD"
  1733. res = dev[0].request(cmd);
  1734. if "FAIL" in res:
  1735. raise Exception("Failed to add configurator")
  1736. conf_id = int(res)
  1737. res = dev[0].request("DPP_QR_CODE " + uri)
  1738. if "FAIL" in res:
  1739. raise Exception("Failed to parse QR Code URI")
  1740. id = int(res)
  1741. cmd = "DPP_AUTH_INIT peer=%d conf=ap-dpp configurator=%d" % (id, conf_id)
  1742. if "OK" not in dev[0].request(cmd):
  1743. raise Exception("Failed to initiate DPP Authentication")
  1744. ev = hapd.wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1745. if ev is None:
  1746. raise Exception("DPP authentication did not succeed (Responder)")
  1747. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  1748. if ev is None:
  1749. raise Exception("DPP authentication did not succeed (Initiator)")
  1750. ev = dev[0].wait_event(["DPP-CONF-SENT"], timeout=5)
  1751. if ev is None:
  1752. raise Exception("DPP configuration not completed (Configurator)")
  1753. ev = hapd.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1754. if ev is None:
  1755. raise Exception("DPP configuration not completed (Enrollee)")
  1756. update_hapd_config(hapd)
  1757. dev[0].set("dpp_config_processing", "1")
  1758. cmd = "DPP_CONFIGURATOR_SIGN conf=sta-dpp configurator=%d" % (conf_id)
  1759. if own_curve:
  1760. cmd += " curve=" + own_curve
  1761. res = dev[0].request(cmd)
  1762. if "FAIL" in res:
  1763. raise Exception("Failed to generate own configuration")
  1764. ev = dev[0].wait_event(["DPP-NETWORK-ID"], timeout=1)
  1765. if ev is None:
  1766. raise Exception("DPP network profile not generated")
  1767. id = ev.split(' ')[1]
  1768. dev[0].select_network(id, freq="2412")
  1769. if expect_failure:
  1770. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
  1771. if ev is not None:
  1772. raise Exception("Unexpected connection");
  1773. dev[0].request("DISCONNECT")
  1774. else:
  1775. dev[0].wait_connected()
  1776. def test_dpp_intro_mismatch(dev, apdev):
  1777. """DPP network introduction mismatch cases"""
  1778. try:
  1779. wpas = None
  1780. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  1781. wpas.interface_add("wlan5")
  1782. check_dpp_capab(wpas)
  1783. run_dpp_intro_mismatch(dev, apdev, wpas)
  1784. finally:
  1785. dev[0].set("dpp_config_processing", "0")
  1786. dev[2].set("dpp_config_processing", "0")
  1787. if wpas:
  1788. wpas.set("dpp_config_processing", "0")
  1789. def run_dpp_intro_mismatch(dev, apdev, wpas):
  1790. check_dpp_capab(dev[0])
  1791. check_dpp_capab(dev[1])
  1792. check_dpp_capab(dev[2])
  1793. logger.info("Start AP in unconfigured state")
  1794. hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" })
  1795. check_dpp_capab(hapd)
  1796. addr = hapd.own_addr().replace(':', '')
  1797. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1798. res = hapd.request(cmd)
  1799. if "FAIL" in res:
  1800. raise Exception("Failed to generate bootstrapping info")
  1801. id_h = int(res)
  1802. uri = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id_h)
  1803. logger.info("Provision AP with DPP configuration")
  1804. res = dev[1].request("DPP_CONFIGURATOR_ADD");
  1805. if "FAIL" in res:
  1806. raise Exception("Failed to add configurator")
  1807. conf_id = int(res)
  1808. res = dev[1].request("DPP_QR_CODE " + uri)
  1809. if "FAIL" in res:
  1810. raise Exception("Failed to parse QR Code URI")
  1811. id = int(res)
  1812. dev[1].set("dpp_groups_override", '[{"groupId":"a","netRole":"ap"}]')
  1813. cmd = "DPP_AUTH_INIT peer=%d conf=ap-dpp configurator=%d" % (id, conf_id)
  1814. if "OK" not in dev[1].request(cmd):
  1815. raise Exception("Failed to initiate DPP Authentication")
  1816. update_hapd_config(hapd)
  1817. logger.info("Provision STA0 with DPP Connector that has mismatching groupId")
  1818. dev[0].set("dpp_config_processing", "2")
  1819. addr = dev[0].own_addr().replace(':', '')
  1820. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1821. res = dev[0].request(cmd)
  1822. if "FAIL" in res:
  1823. raise Exception("Failed to generate bootstrapping info")
  1824. id0 = int(res)
  1825. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1826. res = dev[1].request("DPP_QR_CODE " + uri0)
  1827. if "FAIL" in res:
  1828. raise Exception("Failed to parse QR Code URI")
  1829. id1 = int(res)
  1830. cmd = "DPP_LISTEN 2412"
  1831. if "OK" not in dev[0].request(cmd):
  1832. raise Exception("Failed to start listen operation")
  1833. dev[1].set("dpp_groups_override", '[{"groupId":"b","netRole":"sta"}]')
  1834. cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id1, conf_id)
  1835. if "OK" not in dev[1].request(cmd):
  1836. raise Exception("Failed to initiate DPP Authentication")
  1837. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=5)
  1838. if ev is None:
  1839. raise Exception("DPP configuration not completed (Configurator for STA0)")
  1840. ev = dev[0].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1841. if ev is None:
  1842. raise Exception("DPP configuration not completed (Enrollee STA0)")
  1843. logger.info("Provision STA2 with DPP Connector that has mismatching C-sign-key")
  1844. dev[2].set("dpp_config_processing", "2")
  1845. addr = dev[2].own_addr().replace(':', '')
  1846. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1847. res = dev[2].request(cmd)
  1848. if "FAIL" in res:
  1849. raise Exception("Failed to generate bootstrapping info")
  1850. id2 = int(res)
  1851. uri2 = dev[2].request("DPP_BOOTSTRAP_GET_URI %d" % id2)
  1852. res = dev[1].request("DPP_QR_CODE " + uri2)
  1853. if "FAIL" in res:
  1854. raise Exception("Failed to parse QR Code URI")
  1855. id1 = int(res)
  1856. cmd = "DPP_LISTEN 2412"
  1857. if "OK" not in dev[2].request(cmd):
  1858. raise Exception("Failed to start listen operation")
  1859. res = dev[1].request("DPP_CONFIGURATOR_ADD");
  1860. if "FAIL" in res:
  1861. raise Exception("Failed to add configurator")
  1862. conf_id_2 = int(res)
  1863. dev[1].set("dpp_groups_override", '')
  1864. cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id1, conf_id_2)
  1865. if "OK" not in dev[1].request(cmd):
  1866. raise Exception("Failed to initiate DPP Authentication")
  1867. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=5)
  1868. if ev is None:
  1869. raise Exception("DPP configuration not completed (Configurator for STA2)")
  1870. ev = dev[2].wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1871. if ev is None:
  1872. raise Exception("DPP configuration not completed (Enrollee STA2)")
  1873. logger.info("Provision STA5 with DPP Connector that has mismatching netAccessKey EC group")
  1874. wpas.set("dpp_config_processing", "2")
  1875. addr = wpas.own_addr().replace(':', '')
  1876. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1877. cmd += " curve=P-521"
  1878. res = wpas.request(cmd)
  1879. if "FAIL" in res:
  1880. raise Exception("Failed to generate bootstrapping info")
  1881. id5 = int(res)
  1882. uri5 = wpas.request("DPP_BOOTSTRAP_GET_URI %d" % id5)
  1883. res = dev[1].request("DPP_QR_CODE " + uri5)
  1884. if "FAIL" in res:
  1885. raise Exception("Failed to parse QR Code URI")
  1886. id1 = int(res)
  1887. cmd = "DPP_LISTEN 2412"
  1888. if "OK" not in wpas.request(cmd):
  1889. raise Exception("Failed to start listen operation")
  1890. dev[1].set("dpp_groups_override", '')
  1891. cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id1, conf_id)
  1892. if "OK" not in dev[1].request(cmd):
  1893. raise Exception("Failed to initiate DPP Authentication")
  1894. ev = dev[1].wait_event(["DPP-CONF-SENT"], timeout=5)
  1895. if ev is None:
  1896. raise Exception("DPP configuration not completed (Configurator for STA0)")
  1897. ev = wpas.wait_event(["DPP-CONF-RECEIVED"], timeout=5)
  1898. if ev is None:
  1899. raise Exception("DPP configuration not completed (Enrollee STA5)")
  1900. logger.info("Verify network introduction results")
  1901. ev = dev[0].wait_event(["DPP-INTRO"], timeout=10)
  1902. if ev is None:
  1903. raise Exception("DPP network introduction result not seen on STA0")
  1904. if "status=8" not in ev:
  1905. raise Exception("Unexpected network introduction result on STA0: " + ev)
  1906. ev = dev[2].wait_event(["DPP-INTRO"], timeout=5)
  1907. if ev is None:
  1908. raise Exception("DPP network introduction result not seen on STA2")
  1909. if "status=8" not in ev:
  1910. raise Exception("Unexpected network introduction result on STA2: " + ev)
  1911. ev = wpas.wait_event(["DPP-INTRO"], timeout=10)
  1912. if ev is None:
  1913. raise Exception("DPP network introduction result not seen on STA5")
  1914. if "status=7" not in ev:
  1915. raise Exception("Unexpected network introduction result on STA5: " + ev)
  1916. def run_dpp_proto_init(dev, test_dev, test, mutual=False):
  1917. check_dpp_capab(dev[0])
  1918. check_dpp_capab(dev[1])
  1919. dev[test_dev].set("dpp_test", str(test))
  1920. cmd = "DPP_CONFIGURATOR_ADD"
  1921. res = dev[1].request(cmd);
  1922. if "FAIL" in res:
  1923. raise Exception("Failed to add configurator")
  1924. conf_id = int(res)
  1925. addr = dev[0].own_addr().replace(':', '')
  1926. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
  1927. res = dev[0].request(cmd)
  1928. if "FAIL" in res:
  1929. raise Exception("Failed to generate bootstrapping info")
  1930. id0 = int(res)
  1931. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  1932. res = dev[1].request("DPP_QR_CODE " + uri0)
  1933. if "FAIL" in res:
  1934. raise Exception("Failed to parse QR Code URI")
  1935. id1 = int(res)
  1936. if mutual:
  1937. addr = dev[1].own_addr().replace(':', '')
  1938. res = dev[1].request("DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr)
  1939. if "FAIL" in res:
  1940. raise Exception("Failed to generate bootstrapping info")
  1941. id1b = int(res)
  1942. uri1b = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1b)
  1943. res = dev[0].request("DPP_QR_CODE " + uri1b)
  1944. if "FAIL" in res:
  1945. raise Exception("Failed to parse QR Code URI")
  1946. id0b = int(res)
  1947. cmd = "DPP_LISTEN 2412"
  1948. if "OK" not in dev[0].request(cmd):
  1949. raise Exception("Failed to start listen operation")
  1950. cmd = "DPP_AUTH_INIT peer=%d configurator=%d conf=sta-dpp" % (id1, conf_id)
  1951. if mutual:
  1952. cmd += " own=%d" % id1b
  1953. if "OK" not in dev[1].request(cmd):
  1954. raise Exception("Failed to initiate DPP Authentication")
  1955. def test_dpp_proto_after_wrapped_data_auth_req(dev, apdev):
  1956. """DPP protocol testing - attribute after Wrapped Data in Auth Req"""
  1957. run_dpp_proto_init(dev, 1, 1)
  1958. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  1959. if ev is None:
  1960. raise Exception("DPP Authentication Request not seen")
  1961. if "type=0" not in ev or "ignore=invalid-attributes" not in ev:
  1962. raise Exception("Unexpected RX info: " + ev)
  1963. ev = dev[1].wait_event(["DPP-RX"], timeout=0.1)
  1964. if ev is not None:
  1965. raise Exception("Unexpected DPP message seen")
  1966. def test_dpp_proto_after_wrapped_data_auth_resp(dev, apdev):
  1967. """DPP protocol testing - attribute after Wrapped Data in Auth Resp"""
  1968. run_dpp_proto_init(dev, 0, 2)
  1969. ev = dev[1].wait_event(["DPP-RX"], timeout=5)
  1970. if ev is None:
  1971. raise Exception("DPP Authentication Response not seen")
  1972. if "type=1" not in ev or "ignore=invalid-attributes" not in ev:
  1973. raise Exception("Unexpected RX info: " + ev)
  1974. ev = dev[0].wait_event(["DPP-RX"], timeout=1)
  1975. if ev is None or "type=0" not in ev:
  1976. raise Exception("DPP Authentication Request not seen")
  1977. ev = dev[0].wait_event(["DPP-RX"], timeout=0.1)
  1978. if ev is not None:
  1979. raise Exception("Unexpected DPP message seen")
  1980. def test_dpp_proto_after_wrapped_data_auth_conf(dev, apdev):
  1981. """DPP protocol testing - attribute after Wrapped Data in Auth Conf"""
  1982. run_dpp_proto_init(dev, 1, 3)
  1983. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  1984. if ev is None or "type=0" not in ev:
  1985. raise Exception("DPP Authentication Request not seen")
  1986. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  1987. if ev is None:
  1988. raise Exception("DPP Authentication Confirm not seen")
  1989. if "type=2" not in ev or "ignore=invalid-attributes" not in ev:
  1990. raise Exception("Unexpected RX info: " + ev)
  1991. def test_dpp_proto_after_wrapped_data_conf_req(dev, apdev):
  1992. """DPP protocol testing - attribute after Wrapped Data in Conf Req"""
  1993. run_dpp_proto_init(dev, 0, 6)
  1994. ev = dev[1].wait_event(["DPP-CONF-FAILED"], timeout=10)
  1995. if ev is None:
  1996. raise Exception("DPP Configuration failure not seen")
  1997. def test_dpp_proto_after_wrapped_data_conf_resp(dev, apdev):
  1998. """DPP protocol testing - attribute after Wrapped Data in Conf Resp"""
  1999. run_dpp_proto_init(dev, 1, 7)
  2000. ev = dev[0].wait_event(["DPP-CONF-FAILED"], timeout=10)
  2001. if ev is None:
  2002. raise Exception("DPP Configuration failure not seen")
  2003. def test_dpp_proto_zero_i_capab(dev, apdev):
  2004. """DPP protocol testing - zero I-capability in Auth Req"""
  2005. run_dpp_proto_init(dev, 1, 8)
  2006. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  2007. if ev is None:
  2008. raise Exception("DPP failure not seen")
  2009. if "Invalid role in I-capabilities 0x00" not in ev:
  2010. raise Exception("Unexpected failure: " + ev)
  2011. ev = dev[1].wait_event(["DPP-RX"], timeout=0.1)
  2012. if ev is not None:
  2013. raise Exception("Unexpected DPP message seen")
  2014. def test_dpp_proto_zero_r_capab(dev, apdev):
  2015. """DPP protocol testing - zero R-capability in Auth Resp"""
  2016. run_dpp_proto_init(dev, 0, 9)
  2017. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  2018. if ev is None:
  2019. raise Exception("DPP failure not seen")
  2020. if "Unexpected role in R-capabilities 0x00" not in ev:
  2021. raise Exception("Unexpected failure: " + ev)
  2022. ev = dev[0].wait_event(["DPP-RX"], timeout=1)
  2023. if ev is None or "type=0" not in ev:
  2024. raise Exception("DPP Authentication Request not seen")
  2025. ev = dev[0].wait_event(["DPP-RX"], timeout=0.1)
  2026. if ev is not None:
  2027. raise Exception("Unexpected DPP message seen")
  2028. def run_dpp_proto_auth_req_missing(dev, test, reason):
  2029. run_dpp_proto_init(dev, 1, test)
  2030. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  2031. if ev is None:
  2032. raise Exception("DPP failure not seen")
  2033. if reason not in ev:
  2034. raise Exception("Unexpected failure: " + ev)
  2035. ev = dev[1].wait_event(["DPP-RX"], timeout=0.1)
  2036. if ev is not None:
  2037. raise Exception("Unexpected DPP message seen")
  2038. def test_dpp_proto_auth_req_no_r_bootstrap_key(dev, apdev):
  2039. """DPP protocol testing - no R-bootstrap key in Auth Req"""
  2040. run_dpp_proto_auth_req_missing(dev, 10, "Missing or invalid required Responder Bootstrapping Key Hash attribute")
  2041. def test_dpp_proto_auth_req_no_i_bootstrap_key(dev, apdev):
  2042. """DPP protocol testing - no I-bootstrap key in Auth Req"""
  2043. run_dpp_proto_auth_req_missing(dev, 11, "Missing or invalid required Initiator Bootstrapping Key Hash attribute")
  2044. def test_dpp_proto_auth_req_no_i_proto_key(dev, apdev):
  2045. """DPP protocol testing - no I-proto key in Auth Req"""
  2046. run_dpp_proto_auth_req_missing(dev, 12, "Missing required Initiator Protocol Key attribute")
  2047. def test_dpp_proto_auth_req_no_i_nonce(dev, apdev):
  2048. """DPP protocol testing - no I-nonce in Auth Req"""
  2049. run_dpp_proto_auth_req_missing(dev, 13, "Missing or invalid I-nonce")
  2050. def test_dpp_proto_auth_req_no_i_capab(dev, apdev):
  2051. """DPP protocol testing - no I-capab in Auth Req"""
  2052. run_dpp_proto_auth_req_missing(dev, 14, "Missing or invalid I-capab")
  2053. def test_dpp_proto_auth_req_no_wrapped_data(dev, apdev):
  2054. """DPP protocol testing - no Wrapped Data in Auth Req"""
  2055. run_dpp_proto_auth_req_missing(dev, 15, "Missing or invalid required Wrapped Data attribute")
  2056. def run_dpp_proto_auth_resp_missing(dev, test, reason):
  2057. run_dpp_proto_init(dev, 0, test, mutual=True)
  2058. if reason is None:
  2059. time.sleep(0.1)
  2060. return
  2061. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  2062. if ev is None:
  2063. raise Exception("DPP failure not seen")
  2064. if reason not in ev:
  2065. raise Exception("Unexpected failure: " + ev)
  2066. ev = dev[0].wait_event(["DPP-RX"], timeout=1)
  2067. if ev is None or "type=0" not in ev:
  2068. raise Exception("DPP Authentication Request not seen")
  2069. ev = dev[0].wait_event(["DPP-RX"], timeout=0.1)
  2070. if ev is not None:
  2071. raise Exception("Unexpected DPP message seen")
  2072. def test_dpp_proto_auth_resp_no_status(dev, apdev):
  2073. """DPP protocol testing - no Status in Auth Resp"""
  2074. run_dpp_proto_auth_resp_missing(dev, 16, "Missing or invalid required DPP Status attribute")
  2075. def test_dpp_proto_auth_resp_no_r_bootstrap_key(dev, apdev):
  2076. """DPP protocol testing - no R-bootstrap key in Auth Resp"""
  2077. run_dpp_proto_auth_resp_missing(dev, 17, "Missing or invalid required Responder Bootstrapping Key Hash attribute")
  2078. def test_dpp_proto_auth_resp_no_i_bootstrap_key(dev, apdev):
  2079. """DPP protocol testing - no I-bootstrap key in Auth Resp"""
  2080. run_dpp_proto_auth_resp_missing(dev, 18, None)
  2081. def test_dpp_proto_auth_resp_no_r_proto_key(dev, apdev):
  2082. """DPP protocol testing - no R-Proto Key in Auth Resp"""
  2083. run_dpp_proto_auth_resp_missing(dev, 19, "Missing required Responder Protocol Key attribute")
  2084. def test_dpp_proto_auth_resp_no_r_nonce(dev, apdev):
  2085. """DPP protocol testing - no R-nonce in Auth Resp"""
  2086. run_dpp_proto_auth_resp_missing(dev, 20, "Missing or invalid R-nonce")
  2087. def test_dpp_proto_auth_resp_no_i_nonce(dev, apdev):
  2088. """DPP protocol testing - no I-nonce in Auth Resp"""
  2089. run_dpp_proto_auth_resp_missing(dev, 21, "Missing or invalid I-nonce")
  2090. def test_dpp_proto_auth_resp_no_r_capab(dev, apdev):
  2091. """DPP protocol testing - no R-capab in Auth Resp"""
  2092. run_dpp_proto_auth_resp_missing(dev, 22, "Missing or invalid R-capabilities")
  2093. def test_dpp_proto_auth_resp_no_r_auth(dev, apdev):
  2094. """DPP protocol testing - no R-auth in Auth Resp"""
  2095. run_dpp_proto_auth_resp_missing(dev, 23, "Missing or invalid Secondary Wrapped Data")
  2096. def test_dpp_proto_auth_resp_no_wrapped_data(dev, apdev):
  2097. """DPP protocol testing - no Wrapped Data in Auth Resp"""
  2098. run_dpp_proto_auth_resp_missing(dev, 24, "Missing or invalid required Wrapped Data attribute")
  2099. def test_dpp_proto_auth_resp_i_nonce_mismatch(dev, apdev):
  2100. """DPP protocol testing - I-nonce mismatch in Auth Resp"""
  2101. run_dpp_proto_init(dev, 0, 30, mutual=True)
  2102. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  2103. if ev is None:
  2104. raise Exception("DPP failure not seen")
  2105. if "I-nonce mismatch" not in ev:
  2106. raise Exception("Unexpected failure: " + ev)
  2107. ev = dev[0].wait_event(["DPP-RX"], timeout=1)
  2108. if ev is None or "type=0" not in ev:
  2109. raise Exception("DPP Authentication Request not seen")
  2110. ev = dev[0].wait_event(["DPP-RX"], timeout=0.1)
  2111. if ev is not None:
  2112. raise Exception("Unexpected DPP message seen")
  2113. def test_dpp_proto_auth_resp_incompatible_r_capab(dev, apdev):
  2114. """DPP protocol testing - Incompatible R-capab in Auth Resp"""
  2115. run_dpp_proto_init(dev, 0, 31, mutual=True)
  2116. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  2117. if ev is None:
  2118. raise Exception("DPP failure not seen")
  2119. if "Unexpected role in R-capabilities 0x02" not in ev:
  2120. raise Exception("Unexpected failure: " + ev)
  2121. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  2122. if ev is None:
  2123. raise Exception("DPP failure not seen")
  2124. if "Peer reported incompatible R-capab role" not in ev:
  2125. raise Exception("Unexpected failure: " + ev)
  2126. def test_dpp_proto_auth_resp_r_auth_mismatch(dev, apdev):
  2127. """DPP protocol testing - R-auth mismatch in Auth Resp"""
  2128. run_dpp_proto_init(dev, 0, 32, mutual=True)
  2129. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  2130. if ev is None:
  2131. raise Exception("DPP failure not seen")
  2132. if "Mismatching Responder Authenticating Tag" not in ev:
  2133. raise Exception("Unexpected failure: " + ev)
  2134. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  2135. if ev is None:
  2136. raise Exception("DPP failure not seen")
  2137. if "Peer reported authentication failure" not in ev:
  2138. raise Exception("Unexpected failure: " + ev)
  2139. def run_dpp_proto_auth_conf_missing(dev, test, reason):
  2140. run_dpp_proto_init(dev, 1, test, mutual=True)
  2141. if reason is None:
  2142. time.sleep(0.1)
  2143. return
  2144. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  2145. if ev is None:
  2146. raise Exception("DPP failure not seen")
  2147. if reason not in ev:
  2148. raise Exception("Unexpected failure: " + ev)
  2149. def test_dpp_proto_auth_conf_no_status(dev, apdev):
  2150. """DPP protocol testing - no Status in Auth Conf"""
  2151. run_dpp_proto_auth_conf_missing(dev, 25, "Missing or invalid required DPP Status attribute")
  2152. def test_dpp_proto_auth_conf_no_r_bootstrap_key(dev, apdev):
  2153. """DPP protocol testing - no R-bootstrap key in Auth Conf"""
  2154. run_dpp_proto_auth_conf_missing(dev, 26, "Missing or invalid required Responder Bootstrapping Key Hash attribute")
  2155. def test_dpp_proto_auth_conf_no_i_bootstrap_key(dev, apdev):
  2156. """DPP protocol testing - no I-bootstrap key in Auth Conf"""
  2157. run_dpp_proto_auth_conf_missing(dev, 27, "Missing Initiator Bootstrapping Key Hash attribute")
  2158. def test_dpp_proto_auth_conf_no_i_auth(dev, apdev):
  2159. """DPP protocol testing - no I-Auth in Auth Conf"""
  2160. run_dpp_proto_auth_conf_missing(dev, 28, "Missing or invalid Initiator Authenticating Tag")
  2161. def test_dpp_proto_auth_conf_no_wrapped_data(dev, apdev):
  2162. """DPP protocol testing - no Wrapped Data in Auth Conf"""
  2163. run_dpp_proto_auth_conf_missing(dev, 29, "Missing or invalid required Wrapped Data attribute")
  2164. def test_dpp_proto_auth_conf_i_auth_mismatch(dev, apdev):
  2165. """DPP protocol testing - I-auth mismatch in Auth Conf"""
  2166. run_dpp_proto_init(dev, 1, 33, mutual=True)
  2167. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  2168. if ev is None:
  2169. raise Exception("DPP failure not seen")
  2170. if "Mismatching Initiator Authenticating Tag" not in ev:
  2171. raise Excception("Unexpected failure: " + ev)
  2172. def run_dpp_proto_conf_req_missing(dev, test, reason):
  2173. run_dpp_proto_init(dev, 0, test)
  2174. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  2175. if ev is None:
  2176. raise Exception("DPP failure not seen")
  2177. if reason not in ev:
  2178. raise Exception("Unexpected failure: " + ev)
  2179. def test_dpp_proto_conf_req_no_e_nonce(dev, apdev):
  2180. """DPP protocol testing - no E-nonce in Conf Req"""
  2181. run_dpp_proto_conf_req_missing(dev, 51,
  2182. "Missing or invalid Enrollee Nonce attribute")
  2183. def test_dpp_proto_conf_req_no_config_attr_obj(dev, apdev):
  2184. """DPP protocol testing - no Config Attr Obj in Conf Req"""
  2185. run_dpp_proto_conf_req_missing(dev, 52,
  2186. "Missing or invalid Config Attributes attribute")
  2187. def test_dpp_proto_conf_req_no_wrapped_data(dev, apdev):
  2188. """DPP protocol testing - no Wrapped Data in Conf Req"""
  2189. run_dpp_proto_conf_req_missing(dev, 53,
  2190. "Missing or invalid required Wrapped Data attribute")
  2191. def run_dpp_proto_conf_resp_missing(dev, test, reason):
  2192. run_dpp_proto_init(dev, 1, test)
  2193. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  2194. if ev is None:
  2195. raise Exception("DPP failure not seen")
  2196. if reason not in ev:
  2197. raise Exception("Unexpected failure: " + ev)
  2198. def test_dpp_proto_conf_resp_no_e_nonce(dev, apdev):
  2199. """DPP protocol testing - no E-nonce in Conf Resp"""
  2200. run_dpp_proto_conf_resp_missing(dev, 54,
  2201. "Missing or invalid Enrollee Nonce attribute")
  2202. def test_dpp_proto_conf_resp_no_config_obj(dev, apdev):
  2203. """DPP protocol testing - no Config Object in Conf Resp"""
  2204. run_dpp_proto_conf_resp_missing(dev, 55,
  2205. "Missing required Configuration Object attribute")
  2206. def test_dpp_proto_conf_resp_no_status(dev, apdev):
  2207. """DPP protocol testing - no Status in Conf Resp"""
  2208. run_dpp_proto_conf_resp_missing(dev, 56,
  2209. "Missing or invalid required DPP Status attribute")
  2210. def test_dpp_proto_conf_resp_no_wrapped_data(dev, apdev):
  2211. """DPP protocol testing - no Wrapped Data in Conf Resp"""
  2212. run_dpp_proto_conf_resp_missing(dev, 57,
  2213. "Missing or invalid required Wrapped Data attribute")
  2214. def test_dpp_proto_conf_resp_invalid_status(dev, apdev):
  2215. """DPP protocol testing - invalid Status in Conf Resp"""
  2216. run_dpp_proto_conf_resp_missing(dev, 58,
  2217. "Configurator rejected configuration")
  2218. def test_dpp_proto_conf_resp_e_nonce_mismatch(dev, apdev):
  2219. """DPP protocol testing - E-nonce mismatch in Conf Resp"""
  2220. run_dpp_proto_conf_resp_missing(dev, 59,
  2221. "Enrollee Nonce mismatch")
  2222. def run_dpp_proto_init_pkex(dev, test_dev, test):
  2223. check_dpp_capab(dev[0])
  2224. check_dpp_capab(dev[1])
  2225. dev[test_dev].set("dpp_test", str(test))
  2226. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  2227. res = dev[0].request(cmd)
  2228. if "FAIL" in res:
  2229. raise Exception("Failed to generate bootstrapping info")
  2230. id0 = int(res)
  2231. cmd = "DPP_BOOTSTRAP_GEN type=pkex"
  2232. res = dev[1].request(cmd)
  2233. if "FAIL" in res:
  2234. raise Exception("Failed to generate bootstrapping info")
  2235. id1 = int(res)
  2236. cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id0)
  2237. res = dev[0].request(cmd)
  2238. if "FAIL" in res:
  2239. raise Exception("Failed to set PKEX data (responder)")
  2240. cmd = "DPP_LISTEN 2437"
  2241. if "OK" not in dev[0].request(cmd):
  2242. raise Exception("Failed to start listen operation")
  2243. cmd = "DPP_PKEX_ADD own=%d identifier=test init=1 code=secret" % id1
  2244. res = dev[1].request(cmd)
  2245. if "FAIL" in res:
  2246. raise Exception("Failed to set PKEX data (initiator)")
  2247. def test_dpp_proto_after_wrapped_data_pkex_cr_req(dev, apdev):
  2248. """DPP protocol testing - attribute after Wrapped Data in PKEX CR Req"""
  2249. run_dpp_proto_init_pkex(dev, 1, 4)
  2250. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  2251. if ev is None or "type=7" not in ev:
  2252. raise Exception("PKEX Exchange Request not seen")
  2253. ev = dev[0].wait_event(["DPP-RX"], timeout=5)
  2254. if ev is None or "type=9" not in ev:
  2255. raise Exception("PKEX Commit-Reveal Request not seen")
  2256. if "ignore=invalid-attributes" not in ev:
  2257. raise Exception("Unexpected RX info: " + ev)
  2258. def test_dpp_proto_after_wrapped_data_pkex_cr_resp(dev, apdev):
  2259. """DPP protocol testing - attribute after Wrapped Data in PKEX CR Resp"""
  2260. run_dpp_proto_init_pkex(dev, 0, 5)
  2261. ev = dev[1].wait_event(["DPP-RX"], timeout=5)
  2262. if ev is None or "type=8" not in ev:
  2263. raise Exception("PKEX Exchange Response not seen")
  2264. ev = dev[1].wait_event(["DPP-RX"], timeout=5)
  2265. if ev is None or "type=10" not in ev:
  2266. raise Exception("PKEX Commit-Reveal Response not seen")
  2267. if "ignore=invalid-attributes" not in ev:
  2268. raise Exception("Unexpected RX info: " + ev)
  2269. def run_dpp_proto_pkex_req_missing(dev, test, reason):
  2270. run_dpp_proto_init_pkex(dev, 1, test)
  2271. ev = dev[0].wait_event(["DPP-FAIL"], timeout=5)
  2272. if ev is None:
  2273. raise Exception("DPP failure not seen")
  2274. if reason not in ev:
  2275. raise Exception("Unexpected failure: " + ev)
  2276. def run_dpp_proto_pkex_resp_missing(dev, test, reason):
  2277. run_dpp_proto_init_pkex(dev, 0, test)
  2278. ev = dev[1].wait_event(["DPP-FAIL"], timeout=5)
  2279. if ev is None:
  2280. raise Exception("DPP failure not seen")
  2281. if reason not in ev:
  2282. raise Exception("Unexpected failure: " + ev)
  2283. def test_dpp_proto_pkex_exchange_req_no_finite_cyclic_group(dev, apdev):
  2284. """DPP protocol testing - no Finite Cyclic Group in PKEX Exchange Request"""
  2285. run_dpp_proto_pkex_req_missing(dev, 34,
  2286. "Missing or invalid Finite Cyclic Group attribute")
  2287. def test_dpp_proto_pkex_exchange_req_no_encrypted_key(dev, apdev):
  2288. """DPP protocol testing - no Encrypted Key in PKEX Exchange Request"""
  2289. run_dpp_proto_pkex_req_missing(dev, 35,
  2290. "Missing Encrypted Key attribute")
  2291. def test_dpp_proto_pkex_exchange_resp_no_status(dev, apdev):
  2292. """DPP protocol testing - no Status in PKEX Exchange Response"""
  2293. run_dpp_proto_pkex_resp_missing(dev, 36, "No DPP Status attribute")
  2294. def test_dpp_proto_pkex_exchange_resp_no_encrypted_key(dev, apdev):
  2295. """DPP protocol testing - no Encrypted Key in PKEX Exchange Response"""
  2296. run_dpp_proto_pkex_resp_missing(dev, 37, "Missing Encrypted Key attribute")
  2297. def test_dpp_proto_pkex_cr_req_no_bootstrap_key(dev, apdev):
  2298. """DPP protocol testing - no Bootstrap Key in PKEX Commit-Reveal Request"""
  2299. run_dpp_proto_pkex_req_missing(dev, 38,
  2300. "No valid peer bootstrapping key found")
  2301. def test_dpp_proto_pkex_cr_req_no_i_auth_tag(dev, apdev):
  2302. """DPP protocol testing - no I-Auth Tag in PKEX Commit-Reveal Request"""
  2303. run_dpp_proto_pkex_req_missing(dev, 39, "No valid u (I-Auth tag) found")
  2304. def test_dpp_proto_pkex_cr_req_no_wrapped_data(dev, apdev):
  2305. """DPP protocol testing - no Wrapped Data in PKEX Commit-Reveal Request"""
  2306. run_dpp_proto_pkex_req_missing(dev, 40, "Missing or invalid required Wrapped Data attribute")
  2307. def test_dpp_proto_pkex_cr_resp_no_bootstrap_key(dev, apdev):
  2308. """DPP protocol testing - no Bootstrap Key in PKEX Commit-Reveal Response"""
  2309. run_dpp_proto_pkex_resp_missing(dev, 41,
  2310. "No valid peer bootstrapping key found")
  2311. def test_dpp_proto_pkex_cr_resp_no_r_auth_tag(dev, apdev):
  2312. """DPP protocol testing - no R-Auth Tag in PKEX Commit-Reveal Response"""
  2313. run_dpp_proto_pkex_resp_missing(dev, 42, "No valid v (R-Auth tag) found")
  2314. def test_dpp_proto_pkex_cr_resp_no_wrapped_data(dev, apdev):
  2315. """DPP protocol testing - no Wrapped Data in PKEX Commit-Reveal Response"""
  2316. run_dpp_proto_pkex_resp_missing(dev, 43, "Missing or invalid required Wrapped Data attribute")
  2317. def test_dpp_proto_pkex_exchange_req_invalid_encrypted_key(dev, apdev):
  2318. """DPP protocol testing - invalid Encrypted Key in PKEX Exchange Request"""
  2319. run_dpp_proto_pkex_req_missing(dev, 44,
  2320. "Invalid Encrypted Key value")
  2321. def test_dpp_proto_pkex_exchange_resp_invalid_encrypted_key(dev, apdev):
  2322. """DPP protocol testing - invalid Encrypted Key in PKEX Exchange Response"""
  2323. run_dpp_proto_pkex_resp_missing(dev, 45,
  2324. "Invalid Encrypted Key value")
  2325. def test_dpp_proto_pkex_exchange_resp_invalid_status(dev, apdev):
  2326. """DPP protocol testing - invalid Status in PKEX Exchange Response"""
  2327. run_dpp_proto_pkex_resp_missing(dev, 46,
  2328. "PKEX failed (peer indicated failure)")
  2329. def test_dpp_proto_pkex_cr_req_invalid_bootstrap_key(dev, apdev):
  2330. """DPP protocol testing - invalid Bootstrap Key in PKEX Commit-Reveal Request"""
  2331. run_dpp_proto_pkex_req_missing(dev, 47,
  2332. "Peer bootstrapping key is invalid")
  2333. def test_dpp_proto_pkex_cr_resp_invalid_bootstrap_key(dev, apdev):
  2334. """DPP protocol testing - invalid Bootstrap Key in PKEX Commit-Reveal Response"""
  2335. run_dpp_proto_pkex_resp_missing(dev, 48,
  2336. "Peer bootstrapping key is invalid")
  2337. def test_dpp_proto_pkex_cr_req_i_auth_tag_mismatch(dev, apdev):
  2338. """DPP protocol testing - I-auth tag mismatch in PKEX Commit-Reveal Request"""
  2339. run_dpp_proto_pkex_req_missing(dev, 49, "No valid u (I-Auth tag) found")
  2340. def test_dpp_proto_pkex_cr_resp_r_auth_tag_mismatch(dev, apdev):
  2341. """DPP protocol testing - R-auth tag mismatch in PKEX Commit-Reveal Response"""
  2342. run_dpp_proto_pkex_resp_missing(dev, 50, "No valid v (R-Auth tag) found")
  2343. def test_dpp_proto_network_introduction(dev, apdev):
  2344. """DPP protocol testing - network introduction"""
  2345. check_dpp_capab(dev[0])
  2346. check_dpp_capab(dev[1])
  2347. csign = "3059301306072a8648ce3d020106082a8648ce3d03010703420004d02e5bd81a120762b5f0f2994777f5d40297238a6c294fd575cdf35fabec44c050a6421c401d98d659fd2ed13c961cc8287944dd3202f516977800d3ab2f39ee"
  2348. ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIwOHF4TlNYRzRWemdCV3BjVUdNSmc1czNvbElOVFJsRVQ1aERpNkRKY3ZjIiwieSI6IlVhaGFYQXpKRVpRQk1YaHRUQnlZZVlrOWtJYjk5UDA3UV9NcW9TVVZTVEkifX0.a5_nfMVr7Qe1SW0ZL3u6oQRm5NUCYUSfixDAJOUFN3XUfECBZ6E8fm8xjeSfdOytgRidTz0CTlIRjzPQo82dmQ"
  2349. ap_netaccesskey = "30770201010420f6531d17f29dfab655b7c9e923478d5a345164c489aadd44a3519c3e9dcc792da00a06082a8648ce3d030107a14403420004d3cab13525c6e15ce0056a5c506309839b37a2520d4d19444f98438ba0c972f751a85a5c0cc911940131786d4c1c9879893d9086fdf4fd3b43f32aa125154932"
  2350. sta_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiZWMzR3NqQ3lQMzVBUUZOQUJJdEltQnN4WXVyMGJZX1dES1lfSE9zUGdjNCIsInkiOiJTRS1HVllkdWVnTFhLMU1TQXZNMEx2QWdLREpTNWoyQVhCbE9PMTdUSTRBIn19.PDK9zsGlK-e1pEOmNxVeJfCS8pNeay6ckIS1TXCQsR64AR-9wFPCNVjqOxWvVKltehyMFqVAtOcv0IrjtMJFqQ"
  2351. sta_netaccesskey = "30770201010420bc33380c26fd2168b69cd8242ed1df07ba89aa4813f8d4e8523de6ca3f8dd28ba00a06082a8648ce3d030107a1440342000479cdc6b230b23f7e40405340048b48981b3162eaf46d8fd60ca63f1ceb0f81ce484f8655876e7a02d72b531202f3342ef020283252e63d805c194e3b5ed32380"
  2352. params = { "ssid": "dpp",
  2353. "wpa": "2",
  2354. "wpa_key_mgmt": "DPP",
  2355. "ieee80211w": "2",
  2356. "rsn_pairwise": "CCMP",
  2357. "dpp_connector": ap_connector,
  2358. "dpp_csign": csign,
  2359. "dpp_netaccesskey": ap_netaccesskey }
  2360. try:
  2361. hapd = hostapd.add_ap(apdev[0], params)
  2362. except:
  2363. raise HwsimSkip("DPP not supported")
  2364. for test in [ 60, 61 ]:
  2365. dev[0].set("dpp_test", str(test))
  2366. dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2",
  2367. dpp_csign=csign, dpp_connector=sta_connector,
  2368. dpp_netaccesskey=sta_netaccesskey, wait_connect=False)
  2369. ev = dev[0].wait_event(["DPP-TX"], timeout=10)
  2370. if ev is None or "type=5" not in ev:
  2371. raise Exception("Peer Discovery Request TX not reported")
  2372. ev = dev[0].wait_event(["DPP-TX-STATUS"], timeout=2)
  2373. if ev is None or "result=SUCCESS" not in ev:
  2374. raise Exception("Peer Discovery Request TX status not reported")
  2375. ev = hapd.wait_event(["DPP-RX"], timeout=10)
  2376. if ev is None or "type=5" not in ev:
  2377. raise Exception("Peer Discovery Request RX not reported")
  2378. dev[0].request("REMOVE_NETWORK all")
  2379. dev[0].dump_monitor()
  2380. hapd.dump_monitor()
  2381. dev[0].set("dpp_test", "0")
  2382. for test in [ 62, 63, 64 ]:
  2383. hapd.set("dpp_test", str(test))
  2384. dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2",
  2385. dpp_csign=csign, dpp_connector=sta_connector,
  2386. dpp_netaccesskey=sta_netaccesskey, wait_connect=False)
  2387. ev = dev[0].wait_event(["DPP-INTRO"], timeout=10)
  2388. if ev is None:
  2389. raise Exception("Peer introduction result not reported")
  2390. if "status=" in ev:
  2391. raise Exception("Unexpected peer introduction result: " + ev)
  2392. dev[0].request("REMOVE_NETWORK all")
  2393. dev[0].dump_monitor()
  2394. hapd.dump_monitor()
  2395. hapd.set("dpp_test", "0")
  2396. dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2",
  2397. dpp_csign=csign, dpp_connector=sta_connector,
  2398. dpp_netaccesskey=sta_netaccesskey)
  2399. def test_dpp_qr_code_no_chan_list_unicast(dev, apdev):
  2400. """DPP QR Code and no channel list (unicast)"""
  2401. run_dpp_qr_code_chan_list(dev, apdev, True, 2417, None)
  2402. def test_dpp_qr_code_chan_list_unicast(dev, apdev):
  2403. """DPP QR Code and 2.4 GHz channels (unicast)"""
  2404. run_dpp_qr_code_chan_list(dev, apdev, True, 2417,
  2405. "81/1,81/2,81/3,81/4,81/5,81/6,81/7,81/8,81/9,81/10,81/11,81/12,81/13")
  2406. def test_dpp_qr_code_chan_list_no_peer_unicast(dev, apdev):
  2407. """DPP QR Code and channel list and no peer (unicast)"""
  2408. run_dpp_qr_code_chan_list(dev, apdev, True, 2417, "81/1,81/6,81/11",
  2409. no_wait=True)
  2410. ev = dev[1].wait_event(["DPP-AUTH-INIT-FAILED"], timeout=5)
  2411. if ev is None:
  2412. raise Exception("Initiation failure not reported")
  2413. def test_dpp_qr_code_no_chan_list_broadcast(dev, apdev):
  2414. """DPP QR Code and no channel list (broadcast)"""
  2415. run_dpp_qr_code_chan_list(dev, apdev, False, 2412, None)
  2416. def test_dpp_qr_code_chan_list_broadcast(dev, apdev):
  2417. """DPP QR Code and some 2.4 GHz channels (broadcast)"""
  2418. run_dpp_qr_code_chan_list(dev, apdev, False, 2412, "81/1,81/6,81/11",
  2419. timeout=10)
  2420. def run_dpp_qr_code_chan_list(dev, apdev, unicast, listen_freq, chanlist,
  2421. no_wait=False, timeout=5):
  2422. check_dpp_capab(dev[0])
  2423. check_dpp_capab(dev[1])
  2424. dev[1].set("dpp_init_max_tries", "3")
  2425. dev[1].set("dpp_init_retry_time", "100")
  2426. dev[1].set("dpp_resp_wait_time", "1")
  2427. logger.info("dev0 displays QR Code")
  2428. cmd = "DPP_BOOTSTRAP_GEN type=qrcode"
  2429. if chanlist:
  2430. cmd += " chan=" + chanlist
  2431. if unicast:
  2432. addr = dev[0].own_addr().replace(':', '')
  2433. cmd += " mac=" + addr
  2434. res = dev[0].request(cmd)
  2435. if "FAIL" in res:
  2436. raise Exception("Failed to generate bootstrapping info")
  2437. id0 = int(res)
  2438. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  2439. logger.info("dev1 scans QR Code")
  2440. res = dev[1].request("DPP_QR_CODE " + uri0)
  2441. if "FAIL" in res:
  2442. raise Exception("Failed to parse QR Code URI")
  2443. id1 = int(res)
  2444. logger.info("dev1 initiates DPP Authentication")
  2445. cmd = "DPP_LISTEN %d" % listen_freq
  2446. if "OK" not in dev[0].request(cmd):
  2447. raise Exception("Failed to start listen operation")
  2448. cmd = "DPP_AUTH_INIT peer=%d" % id1
  2449. if "OK" not in dev[1].request(cmd):
  2450. raise Exception("Failed to initiate DPP Authentication")
  2451. if no_wait:
  2452. return
  2453. ev = dev[0].wait_event(["DPP-AUTH-SUCCESS"], timeout=timeout)
  2454. if ev is None:
  2455. raise Exception("DPP authentication did not succeed (Responder)")
  2456. ev = dev[1].wait_event(["DPP-AUTH-SUCCESS"], timeout=5)
  2457. if ev is None:
  2458. raise Exception("DPP authentication did not succeed (Initiator)")
  2459. ev = dev[0].wait_event(["DPP-CONF-RECEIVED", "DPP-CONF-FAILED"], timeout=5)
  2460. if ev is None:
  2461. raise Exception("DPP configuration not completed (Enrollee)")
  2462. dev[0].request("DPP_STOP_LISTEN")
  2463. dev[0].dump_monitor()
  2464. dev[1].dump_monitor()
  2465. def test_dpp_qr_code_chan_list_no_match(dev, apdev):
  2466. """DPP QR Code and no matching supported channel"""
  2467. check_dpp_capab(dev[0])
  2468. check_dpp_capab(dev[1])
  2469. cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=123/123"
  2470. res = dev[0].request(cmd)
  2471. if "FAIL" in res:
  2472. raise Exception("Failed to generate bootstrapping info")
  2473. id0 = int(res)
  2474. uri0 = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id0)
  2475. res = dev[1].request("DPP_QR_CODE " + uri0)
  2476. if "FAIL" in res:
  2477. raise Exception("Failed to parse QR Code URI")
  2478. id1 = int(res)
  2479. cmd = "DPP_AUTH_INIT peer=%d" % id1
  2480. if "FAIL" not in dev[1].request(cmd):
  2481. raise Exception("DPP Authentication started unexpectedly")