• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3.4
2#
3#   Copyright 2018 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17import binascii
18import queue
19import time
20
21from acts import asserts
22from acts import utils
23from acts.test_decorators import test_tracker_info
24from acts_contrib.test_utils.wifi import wifi_constants
25from acts_contrib.test_utils.wifi import wifi_test_utils as wutils
26from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest
27from acts_contrib.test_utils.wifi.aware import aware_test_utils as autils
28
29class WifiDppTest(WifiBaseTest):
30  """This class tests the DPP API surface.
31
32     Attributes: The tests in this class require one DUT and one helper phone
33     device.
34     The tests in this class do not require a SIM.
35  """
36
37  DPP_TEST_TIMEOUT = 60
38  DPP_TEST_SSID_PREFIX = "dpp_test_ssid_"
39  DPP_TEST_SECURITY_SAE = "SAE"
40  DPP_TEST_SECURITY_PSK_PASSPHRASE = "PSK_PASSPHRASE"
41  DPP_TEST_SECURITY_PSK = "PSK"
42
43  DPP_TEST_EVENT_DPP_CALLBACK = "onDppCallback"
44  DPP_TEST_EVENT_DATA = "data"
45  DPP_TEST_EVENT_ENROLLEE_SUCCESS = "onEnrolleeSuccess"
46  DPP_TEST_EVENT_CONFIGURATOR_SUCCESS = "onConfiguratorSuccess"
47  DPP_TEST_EVENT_PROGRESS = "onProgress"
48  DPP_TEST_EVENT_FAILURE = "onFailure"
49  DPP_TEST_EVENT_URI_GENERATED = "onBootstrapUriGenerated"
50  DPP_TEST_MESSAGE_TYPE = "Type"
51  DPP_TEST_MESSAGE_STATUS = "Status"
52  DPP_TEST_MESSAGE_NETWORK_ID = "NetworkId"
53  DPP_TEST_MESSAGE_FAILURE_SSID = "onFailureSsid"
54  DPP_TEST_MESSAGE_FAILURE_CHANNEL_LIST = "onFailureChannelList"
55  DPP_TEST_MESSAGE_FAILURE_BAND_LIST = "onFailureBandList"
56  DPP_TEST_MESSAGE_GENERATED_URI = "generatedUri"
57
58  DPP_TEST_NETWORK_ROLE_STA = "sta"
59  DPP_TEST_NETWORK_ROLE_AP = "ap"
60
61  DPP_TEST_PARAM_SSID = "SSID"
62  DPP_TEST_PARAM_PASSWORD = "password"
63
64  WPA_SUPPLICANT_SECURITY_SAE = "sae"
65  WPA_SUPPLICANT_SECURITY_PSK = "psk"
66
67  DPP_TEST_CRYPTOGRAPHY_CURVE_PRIME256V1 = "prime256v1"
68  DPP_TEST_CRYPTOGRAPHY_CURVE_SECP384R1 = "secp384r1"
69  DPP_TEST_CRYPTOGRAPHY_CURVE_SECP521R1 = "secp521r1"
70  DPP_TEST_CRYPTOGRAPHY_CURVE_BRAINPOOLP256R1 = "brainpoolP256r1"
71  DPP_TEST_CRYPTOGRAPHY_CURVE_BRAINPOOLP384R1 = "brainpoolp384r1"
72  DPP_TEST_CRYPTOGRAPHY_CURVE_BRAINPOOLP512R1 = "brainpoolP512r1"
73
74  DPP_EVENT_PROGRESS_AUTHENTICATION_SUCCESS = 0
75  DPP_EVENT_PROGRESS_RESPONSE_PENDING = 1
76  DPP_EVENT_PROGRESS_CONFIGURATION_SENT_WAITING_RESPONSE = 2
77  DPP_EVENT_PROGRESS_CONFIGURATION_ACCEPTED = 3
78
79  DPP_EVENT_SUCCESS_CONFIGURATION_SENT = 0
80  DPP_EVENT_SUCCESS_CONFIGURATION_APPLIED = 1
81
82  def setup_class(self):
83    """ Sets up the required dependencies from the config file and configures the device for
84        WifiService API tests.
85
86        Returns:
87          True is successfully configured the requirements for testing.
88    """
89    super().setup_class()
90    # Device 0 is under test. Device 1 performs the responder role
91    self.dut = self.android_devices[0]
92    self.helper_dev = self.android_devices[1]
93
94    # Do a simple version of init - mainly just sync the time and enable
95    # verbose logging.  We would also like to test with phones in less
96    # constrained states (or add variations where we specifically
97    # constrain).
98    utils.require_sl4a((self.dut,))
99    utils.sync_device_time(self.dut)
100
101    req_params = ["dpp_r1_test_only"]
102    opt_param = ["wifi_psk_network", "wifi_sae_network"]
103    self.unpack_userparams(
104      req_param_names=req_params, opt_param_names=opt_param)
105    if "OpenWrtAP" in self.user_params:
106      self.configure_openwrt_ap_and_start(wpa_network=True,
107                                          sae_network=True)
108      self.wifi_psk_network = self.wpa_networks[0]["5g"].copy()
109      self.wifi_sae_network = self.sae_networks[0]["2g"].copy()
110
111    self.dut.log.info(
112      "Parsed configs: %s %s" % (self.wifi_psk_network, self.wifi_sae_network))
113
114    # Set up the networks. This is optional. In case these networks are not initialized,
115    # the script will create random ones. However, a real AP is required to pass DPP R2 test.
116    # Most efficient setup would be to use an AP in WPA2/WPA3 transition mode.
117    if self.DPP_TEST_PARAM_SSID in self.wifi_psk_network:
118      self.psk_network_ssid = self.wifi_psk_network[self.DPP_TEST_PARAM_SSID]
119    else:
120      self.psk_network_ssid = None
121
122    if self.DPP_TEST_PARAM_PASSWORD in self.wifi_psk_network:
123      self.psk_network_password = self.wifi_psk_network[self.DPP_TEST_PARAM_PASSWORD]
124    else:
125      self.psk_network_ssid = None
126
127    if self.DPP_TEST_PARAM_SSID in self.wifi_sae_network:
128      self.sae_network_ssid = self.wifi_sae_network[self.DPP_TEST_PARAM_SSID]
129    else:
130      self.sae_network_ssid = None
131
132    if self.DPP_TEST_PARAM_PASSWORD in self.wifi_sae_network:
133      self.sae_network_password = self.wifi_sae_network[self.DPP_TEST_PARAM_PASSWORD]
134    else:
135      self.sae_network_ssid = None
136
137    if self.dpp_r1_test_only == "False":
138      if not self.wifi_psk_network or not self.wifi_sae_network:
139        asserts.fail("Must specify wifi_psk_network and wifi_sae_network for DPP R2 tests")
140
141    # Enable verbose logging on the dut
142    self.dut.droid.wifiEnableVerboseLogging(1)
143    asserts.assert_true(self.dut.droid.wifiGetVerboseLoggingLevel() == 1,
144                        "Failed to enable WiFi verbose logging on the dut.")
145
146  def teardown_class(self):
147    wutils.reset_wifi(self.dut)
148
149  def create_and_save_wifi_network_config(self, security, random_network=False,
150                                          r2_auth_error=False):
151    """ Create a config with random SSID and password.
152
153            Args:
154               security: Security type: PSK or SAE
155               random_network: A boolean that indicates if to create a random network
156               r2_auth_error: A boolean that indicates if to create a network with a bad password
157
158            Returns:
159               A tuple with the config and networkId for the newly created and
160               saved network.
161    """
162    if security == self.DPP_TEST_SECURITY_PSK or \
163              security == self.DPP_TEST_SECURITY_PSK_PASSPHRASE:
164      if self.psk_network_ssid is None or self.psk_network_password is None or \
165              random_network is True:
166        config_ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8)
167        config_password = utils.rand_ascii_str(8)
168      else:
169        config_ssid = self.psk_network_ssid
170        if r2_auth_error:
171          config_password = utils.rand_ascii_str(8)
172        else:
173          config_password = self.psk_network_password
174    else:
175      if self.sae_network_ssid is None or self.sae_network_password is None or \
176              random_network is True:
177        config_ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8)
178        config_password = utils.rand_ascii_str(8)
179      else:
180        config_ssid = self.sae_network_ssid
181        if r2_auth_error:
182          config_password = utils.rand_ascii_str(8)
183        else:
184          config_password = self.sae_network_password
185
186    self.dut.log.info(
187        "creating config: %s %s %s" % (config_ssid, config_password, security))
188    config = {
189        wutils.WifiEnums.SSID_KEY: config_ssid,
190        wutils.WifiEnums.PWD_KEY: config_password,
191        wutils.WifiEnums.SECURITY: security
192    }
193
194    # Now save the config.
195    network_id = self.dut.droid.wifiAddNetwork(config)
196    self.dut.log.info("saved config: network_id = %d" % network_id)
197    return network_id
198
199  def check_network_config_saved(self, expected_ssid, security, network_id):
200    """ Get the configured networks and check if the provided network ID is present.
201
202            Args:
203             expected_ssid: Expected SSID to match with received configuration.
204             security: Security type to match, PSK or SAE
205
206            Returns:
207                True if the WifiConfig is present.
208    """
209    networks = self.dut.droid.wifiGetConfiguredNetworks()
210    if not networks:
211      return False
212
213    # Normalize PSK and PSK Passphrase to PSK
214    if security == self.DPP_TEST_SECURITY_PSK_PASSPHRASE:
215      security = self.DPP_TEST_SECURITY_PSK
216
217    # If the device doesn't support SAE, then the test fallbacks to PSK
218    if not self.dut.droid.wifiIsWpa3SaeSupported() and \
219              security == self.DPP_TEST_SECURITY_SAE:
220      security = self.DPP_TEST_SECURITY_PSK
221
222    for network in networks:
223      if network_id == network['networkId'] and \
224              security == network[wutils.WifiEnums.SECURITY] and \
225              expected_ssid == network[wutils.WifiEnums.SSID_KEY]:
226        self.log.info("Found SSID %s" % network[wutils.WifiEnums.SSID_KEY])
227        return True
228    return False
229
230  def forget_network(self, network_id):
231    """ Simple method to call wifiForgetNetwork and wait for confirmation callback.
232
233            Returns:
234                True if network was successfully deleted.
235        """
236    self.dut.log.info("Deleting config: networkId = %s" % network_id)
237    self.dut.droid.wifiForgetNetwork(network_id)
238    try:
239      event = self.dut.ed.pop_event(wifi_constants.WIFI_FORGET_NW_SUCCESS, 10)
240      return True
241    except queue.Empty:
242      self.dut.log.error("Failed to forget network")
243      return False
244
245  def gen_uri(self, device, info="DPP_TESTER", chan="81/1", mac=None):
246    """Generate a URI on a device
247
248            Args:
249                device: Device object
250                mac: MAC address to use
251                info: Optional info to be embedded in URI
252                chan: Optional channel info
253
254            Returns:
255             URI ID to be used later
256    """
257
258    # Clean up any previous URIs
259    self.del_uri(device, "'*'")
260
261    self.log.info("Generating a URI for the Responder")
262    cmd = "wpa_cli -iwlan0 DPP_BOOTSTRAP_GEN type=qrcode info=%s" % info
263
264    if mac:
265      cmd += " mac=%s" % mac
266
267    if chan:
268      cmd += " chan=%s" % chan
269
270    result = device.adb.shell(cmd)
271
272    if "FAIL" in result:
273      asserts.fail("gen_uri: Failed to generate a URI. Command used: %s" % cmd)
274
275    device.log.info("Generated URI, id = %s" % result)
276
277    return result
278
279  def get_uri(self, device, uri_id):
280    """Get a previously generated URI from a device
281
282            Args:
283                device: Device object
284                uri_id: URI ID returned by gen_uri method
285
286            Returns:
287                URI string
288
289        """
290    self.log.info("Reading the contents of the URI of the Responder")
291    cmd = "wpa_cli -iwlan0 DPP_BOOTSTRAP_GET_URI %s" % uri_id
292    result = device.adb.shell(cmd)
293
294    if "FAIL" in result:
295      asserts.fail("get_uri: Failed to read URI. Command used: %s" % cmd)
296
297    device.log.info("URI contents = %s" % result)
298
299    return result
300
301  def del_uri(self, device, uri_id):
302    """Delete a previously generated URI
303
304          Args:
305          device: Device object
306          uri_id: URI ID returned by gen_uri method
307    """
308    self.log.info("Deleting the Responder URI")
309    cmd = "wpa_cli -iwlan0 DPP_BOOTSTRAP_REMOVE %s" % uri_id
310    result = device.adb.shell(cmd)
311
312    # If URI was already flushed, ignore a failure here
313    if "FAIL" not in result:
314      device.log.info("Deleted URI, id = %s" % uri_id)
315
316  def start_responder_configurator(self,
317                                   device,
318                                   freq=2412,
319                                   net_role=DPP_TEST_NETWORK_ROLE_STA,
320                                   security=DPP_TEST_SECURITY_SAE,
321                                   invalid_config=False):
322    """Start a responder on helper device
323
324           Args:
325               device: Device object
326               freq: Frequency to listen on
327               net_role: Network role to configure
328               security: Security type: SAE or PSK
329               invalid_config: Send invalid configuration (negative test)
330
331            Returns:
332                ssid: SSID name of the network to be configured
333
334        """
335    if not net_role or (net_role != self.DPP_TEST_NETWORK_ROLE_STA and
336                        net_role != self.DPP_TEST_NETWORK_ROLE_AP):
337      asserts.fail("start_responder: Must specify net_role sta or ap")
338
339    self.log.info("Starting Responder in Configurator mode, frequency %sMHz" % freq)
340
341    conf = "conf=%s-" % net_role
342
343    use_psk = False
344
345    if security == self.DPP_TEST_SECURITY_SAE:
346      if not self.dut.droid.wifiIsWpa3SaeSupported():
347        self.log.warning("SAE not supported on device! reverting to PSK")
348        security = self.DPP_TEST_SECURITY_PSK_PASSPHRASE
349
350    ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8)
351    password = utils.rand_ascii_str(8)
352
353    if security == self.DPP_TEST_SECURITY_SAE:
354      conf += self.WPA_SUPPLICANT_SECURITY_SAE
355      if not self.sae_network_ssid is None:
356        ssid = self.sae_network_ssid
357        password = self.sae_network_password
358    elif security == self.DPP_TEST_SECURITY_PSK_PASSPHRASE:
359      conf += self.WPA_SUPPLICANT_SECURITY_PSK
360      if not self.psk_network_ssid is None:
361        ssid = self.psk_network_ssid
362        password = self.psk_network_password
363    else:
364      conf += self.WPA_SUPPLICANT_SECURITY_PSK
365      use_psk = True
366
367    self.log.debug("SSID = %s" % ssid)
368
369    ssid_encoded = binascii.hexlify(ssid.encode()).decode()
370
371    if use_psk:
372      psk = utils.rand_ascii_str(16)
373      if not invalid_config:
374        psk_encoded = binascii.b2a_hex(psk.encode()).decode()
375      else:
376        # Use the psk as is without hex encoding, will make it invalid
377        psk_encoded = psk
378      self.log.debug("PSK = %s" % psk)
379    else:
380      if not invalid_config:
381        password_encoded = binascii.b2a_hex(password.encode()).decode()
382      else:
383        # Use the password as is without hex encoding, will make it invalid
384        password_encoded = password
385      self.log.debug("Password = %s" % password)
386
387    conf += " ssid=%s" % ssid_encoded
388
389    if password:  # SAE password or PSK passphrase
390      conf += " pass=%s" % password_encoded
391    else:  # PSK
392      conf += " psk=%s" % psk_encoded
393
394    # Stop responder first
395    self.stop_responder(device)
396
397    cmd = "wpa_cli -iwlan0 set dpp_configurator_params guard=1 %s" % conf
398    device.log.debug("Command used: %s" % cmd)
399    result = self.helper_dev.adb.shell(cmd)
400    if "FAIL" in result:
401      asserts.fail(
402          "start_responder_configurator: Failure. Command used: %s" % cmd)
403
404    cmd = "wpa_cli -iwlan0 DPP_LISTEN %d role=configurator netrole=%s" % (freq,
405                                                                  net_role)
406    device.log.debug("Command used: %s" % cmd)
407    result = self.helper_dev.adb.shell(cmd)
408    if "FAIL" in result:
409      asserts.fail(
410          "start_responder_configurator: Failure. Command used: %s" % cmd)
411
412    device.log.info("Started responder in configurator mode")
413    return ssid
414
415  def start_responder_enrollee(self,
416                               device,
417                               freq=2412,
418                               net_role=DPP_TEST_NETWORK_ROLE_STA):
419    """Start a responder-enrollee on helper device
420
421           Args:
422               device: Device object
423               freq: Frequency to listen on
424               net_role: Network role to request
425
426            Returns:
427                ssid: SSID name of the network to be configured
428
429        """
430    if not net_role or (net_role != self.DPP_TEST_NETWORK_ROLE_STA and
431                        net_role != self.DPP_TEST_NETWORK_ROLE_AP):
432      asserts.fail("start_responder: Must specify net_role sta or ap")
433
434    # Stop responder first
435    self.stop_responder(device)
436    self.log.info("Starting Responder in Enrollee mode, frequency %sMHz" % freq)
437
438    cmd = "wpa_cli -iwlan0 DPP_LISTEN %d role=enrollee netrole=%s" % (freq, net_role)
439    result = device.adb.shell(cmd)
440
441    if "FAIL" in result:
442      asserts.fail("start_responder_enrollee: Failure. Command used: %s" % cmd)
443
444    device.adb.shell("wpa_cli -iwlan0 set dpp_config_processing 2")
445
446    device.log.info("Started responder in enrollee mode")
447
448  def stop_responder(self, device, flush=False):
449    """Stop responder on helper device
450
451       Args:
452           device: Device object
453    """
454    result = device.adb.shell("wpa_cli -iwlan0 DPP_STOP_LISTEN")
455    if "FAIL" in result:
456      asserts.fail("stop_responder: Failed to stop responder")
457    device.adb.shell("wpa_cli -iwlan0 set dpp_configurator_params")
458    device.adb.shell("wpa_cli -iwlan0 set dpp_config_processing 0")
459    if flush:
460      device.adb.shell("wpa_cli -iwlan0 flush")
461    device.log.info("Stopped responder")
462
463  def start_dpp_as_initiator_configurator(self,
464                                          security,
465                                          use_mac,
466                                          responder_chan="81/1",
467                                          responder_freq=2412,
468                                          net_role=DPP_TEST_NETWORK_ROLE_STA,
469                                          cause_timeout=False,
470                                          fail_authentication=False,
471                                          invalid_uri=False,
472                                          r2_no_ap=False,
473                                          r2_auth_error=False):
474    """ Test Easy Connect (DPP) as initiator configurator.
475
476                1. Enable wifi, if needed
477                2. Create and save a random config.
478                3. Generate a URI using the helper device
479                4. Start DPP as responder-enrollee on helper device
480                5. Start DPP as initiator configurator on dut
481                6. Check if configurator sent successfully
482                7. Delete the URI from helper device
483                8. Remove the config.
484
485        Args:
486            security: Security type, a string "SAE" or "PSK"
487            use_mac: A boolean indicating whether to use the device's MAC
488              address (if True) or use a Broadcast (if False).
489            responder_chan: Responder channel to specify in the URI
490            responder_freq: Frequency that the Responder would actually listen on.
491              Note: To succeed, there must be a correlation between responder_chan, which is what
492              the URI advertises, and responder_freq which is the actual frequency. See:
493              https://en.wikipedia.org/wiki/List_of_WLAN_channels
494            net_role: Network role, a string "sta" or "ap"
495            cause_timeout: Intentionally don't start the responder to cause a
496              timeout
497            fail_authentication: Fail authentication by corrupting the
498              responder's key
499            invalid_uri: Use garbage string instead of a URI
500            r2_no_ap: Indicates if to test DPP R2 no AP failure event
501            r2_auth_error: Indicates if to test DPP R2 authentication failure
502    """
503    if not self.dut.droid.wifiIsEasyConnectSupported():
504      self.log.warning("Easy Connect is not supported on device!")
505      return
506
507    wutils.wifi_toggle_state(self.dut, True)
508    test_network_id = self.create_and_save_wifi_network_config(security, random_network=r2_no_ap,
509                                                               r2_auth_error=r2_auth_error)
510
511    if use_mac:
512      mac = autils.get_mac_addr(self.helper_dev, "wlan0")
513    else:
514      mac = None
515
516    if invalid_uri:
517      enrollee_uri = "dskjgnkdjfgnkdsjfgnsDFGDIFGKDSJFGFDbgjdsnbkjdfnkbgsdfgFDSGSDfgesouhgureho" \
518                     "iu3ht98368903434089ut4958763094u0934ujg094j5oifegjfds"
519    else:
520      # Generate a URI with default info and channel
521      uri_id = self.gen_uri(self.helper_dev, chan=responder_chan, mac=mac)
522
523      # Get the URI. This is equal to scanning a QR code
524      enrollee_uri = self.get_uri(self.helper_dev, uri_id)
525
526      # Corrupt the responder key if required
527      if fail_authentication:
528        enrollee_uri = enrollee_uri[:80] + "DeAdBeeF" + enrollee_uri[88:]
529        self.log.info("Corrupted enrollee URI: %s" % enrollee_uri)
530
531    if not cause_timeout:
532      # Start DPP as an enrolle-responder for STA on helper device
533      self.start_responder_enrollee(self.helper_dev, freq=responder_freq, net_role=net_role)
534    else:
535      self.log.info("Not starting DPP responder on purpose")
536
537    self.log.info("Starting DPP in Configurator-Initiator mode")
538
539    # Start DPP as configurator-initiator on dut
540    self.dut.droid.startEasyConnectAsConfiguratorInitiator(enrollee_uri,
541                                                   test_network_id, net_role)
542
543    start_time = time.time()
544    while time.time() < start_time + self.DPP_TEST_TIMEOUT:
545      dut_event = self.dut.ed.pop_event(self.DPP_TEST_EVENT_DPP_CALLBACK,
546                                        self.DPP_TEST_TIMEOUT)
547      if dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_TYPE] \
548              == self.DPP_TEST_EVENT_ENROLLEE_SUCCESS:
549        asserts.fail("DPP failure, unexpected result!")
550        break
551      if dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_TYPE] \
552              == self.DPP_TEST_EVENT_CONFIGURATOR_SUCCESS:
553        if cause_timeout or fail_authentication or invalid_uri or r2_no_ap or r2_auth_error:
554          asserts.fail(
555              "Unexpected DPP success, status code: %s" %
556              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS])
557        else:
558          val = dut_event[self.DPP_TEST_EVENT_DATA][
559              self.DPP_TEST_MESSAGE_STATUS]
560          if val == self.DPP_EVENT_SUCCESS_CONFIGURATION_SENT:
561            self.dut.log.info("DPP Configuration sent success")
562          if val == self.DPP_EVENT_SUCCESS_CONFIGURATION_APPLIED:
563            self.dut.log.info("DPP Configuration applied by enrollee")
564        break
565      if dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_TYPE] \
566              == self.DPP_TEST_EVENT_PROGRESS:
567        self.dut.log.info("DPP progress event")
568        val = dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS]
569        if val == self.DPP_EVENT_PROGRESS_AUTHENTICATION_SUCCESS:
570          self.dut.log.info("DPP Authentication success")
571        elif val == self.DPP_EVENT_PROGRESS_RESPONSE_PENDING:
572          self.dut.log.info("DPP Response pending")
573        elif val == self.DPP_EVENT_PROGRESS_CONFIGURATION_SENT_WAITING_RESPONSE:
574          self.dut.log.info("DPP Configuration sent, waiting response")
575        elif val == self.DPP_EVENT_PROGRESS_CONFIGURATION_ACCEPTED:
576          self.dut.log.info("Configuration accepted")
577        continue
578      if dut_event[self.DPP_TEST_EVENT_DATA][
579          self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_FAILURE:
580        if cause_timeout or fail_authentication or invalid_uri or r2_no_ap or r2_auth_error:
581          self.dut.log.info(
582              "Error %s occurred, as expected" %
583              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS])
584          if r2_no_ap or r2_auth_error:
585            if not dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_SSID]:
586              asserts.fail("Expected SSID value in DPP R2 onFailure event")
587            self.dut.log.info(
588              "Enrollee searched for SSID %s" %
589              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_SSID])
590          if r2_no_ap:
591            if not dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_CHANNEL_LIST]:
592              asserts.fail("Expected Channel list value in DPP R2 onFailure event")
593            self.dut.log.info(
594              "Enrollee scanned the following channels: %s" %
595              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_CHANNEL_LIST])
596          if r2_no_ap or r2_auth_error:
597            if not dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_BAND_LIST]:
598              asserts.fail("Expected Band Support list value in DPP R2 onFailure event")
599            self.dut.log.info(
600              "Enrollee supports the following bands: %s" %
601              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_BAND_LIST])
602        else:
603          asserts.fail(
604              "DPP failure, status code: %s" %
605              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS])
606        break
607
608    # Clear all pending events.
609    self.dut.ed.clear_all_events()
610
611    # Stop responder
612    self.stop_responder(self.helper_dev, flush=True)
613
614    if not invalid_uri:
615      # Delete URI
616      self.del_uri(self.helper_dev, uri_id)
617
618    asserts.assert_true(
619        self.forget_network(test_network_id),
620        "Test network not deleted from configured networks.")
621
622  def start_dpp_as_initiator_enrollee(self,
623                                      security,
624                                      use_mac,
625                                      cause_timeout=False,
626                                      invalid_config=False):
627    """ Test Easy Connect (DPP) as initiator enrollee.
628
629                1. Enable wifi, if needed
630                2. Start DPP as responder-configurator on helper device
631                3. Start DPP as initiator enrollee on dut
632                4. Check if configuration received successfully
633                5. Delete the URI from helper device
634                6. Remove the config.
635
636        Args:
637            security: Security type, a string "SAE" or "PSK"
638            use_mac: A boolean indicating whether to use the device's MAC
639              address (if True) or use a Broadcast (if False).
640            cause_timeout: Intentionally don't start the responder to cause a
641              timeout
642            invalid_config: Responder to intentionally send malformed
643              configuration
644    """
645    if not self.dut.droid.wifiIsEasyConnectSupported():
646      self.log.warning("Easy Connect is not supported on device!")
647      return
648
649    wutils.wifi_toggle_state(self.dut, True)
650
651    if use_mac:
652      mac = autils.get_mac_addr(self.helper_dev, "wlan0")
653    else:
654      mac = None
655
656    # Generate a URI with default info and channel
657    uri_id = self.gen_uri(self.helper_dev, mac=mac)
658
659    # Get the URI. This is equal to scanning a QR code
660    configurator_uri = self.get_uri(self.helper_dev, uri_id)
661
662    if not cause_timeout:
663      # Start DPP as an configurator-responder for STA on helper device
664      ssid = self.start_responder_configurator(
665          self.helper_dev, security=security, invalid_config=invalid_config)
666    else:
667      self.log.info(
668          "Not starting a responder configurator on helper device, on purpose")
669      ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8)
670
671    self.log.info("Starting DPP in Enrollee-Initiator mode")
672
673    # Start DPP as enrollee-initiator on dut
674    self.dut.droid.startEasyConnectAsEnrolleeInitiator(configurator_uri)
675
676    network_id = 0
677
678    start_time = time.time()
679    while time.time() < start_time + self.DPP_TEST_TIMEOUT:
680      dut_event = self.dut.ed.pop_event(self.DPP_TEST_EVENT_DPP_CALLBACK,
681                                        self.DPP_TEST_TIMEOUT)
682      if dut_event[self.DPP_TEST_EVENT_DATA][
683          self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_ENROLLEE_SUCCESS:
684        if cause_timeout or invalid_config:
685          asserts.fail(
686              "Unexpected DPP success, status code: %s" %
687              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS])
688        else:
689          self.dut.log.info("DPP Configuration received success")
690          network_id = dut_event[self.DPP_TEST_EVENT_DATA][
691              self.DPP_TEST_MESSAGE_NETWORK_ID]
692          self.dut.log.info("NetworkID: %d" % network_id)
693        break
694      if dut_event[self.DPP_TEST_EVENT_DATA][
695          self
696          .DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_CONFIGURATOR_SUCCESS:
697        asserts.fail(
698            "DPP failure, unexpected result: %s" %
699            dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS])
700        break
701      if dut_event[self.DPP_TEST_EVENT_DATA][
702          self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_PROGRESS:
703        self.dut.log.info("DPP progress event")
704        val = dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS]
705        if val == 0:
706          self.dut.log.info("DPP Authentication success")
707        elif val == 1:
708          self.dut.log.info("DPP Response pending")
709        continue
710      if dut_event[self.DPP_TEST_EVENT_DATA][
711          self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_FAILURE:
712        if cause_timeout or invalid_config:
713          self.dut.log.info(
714              "Error %s occurred, as expected" %
715              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS])
716        else:
717          asserts.fail(
718              "DPP failure, status code: %s" %
719              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS])
720        break
721      asserts.fail("Unknown message received")
722
723    # Clear all pending events.
724    self.dut.ed.clear_all_events()
725
726    # Stop responder
727    self.stop_responder(self.helper_dev, flush=True)
728
729    # Delete URI
730    self.del_uri(self.helper_dev, uri_id)
731
732    if not (invalid_config or cause_timeout):
733      # Check that the saved network is what we expect
734      asserts.assert_true(
735          self.check_network_config_saved(ssid, security, network_id),
736          "Could not find the expected network: %s" % ssid)
737
738      asserts.assert_true(
739          self.forget_network(network_id),
740          "Test network not deleted from configured networks.")
741
742  def stop_initiator(self, device, flush=False):
743    """Stop initiator on helper device
744
745       Args:
746           device: Device object
747    """
748    result = device.adb.shell("wpa_cli -iwlan0 DPP_STOP_LISTEN")
749    if "FAIL" in result:
750      asserts.fail("stop_initiator: Failed to stop initiator")
751    if flush:
752      device.adb.shell("wpa_cli -iwlan0 flush")
753    device.log.info("Stopped initiator")
754
755  def start_initiator_configurator(self,
756                                   device,
757                                   uri,
758                                   security=DPP_TEST_SECURITY_SAE):
759    """Start a responder on helper device
760
761        Args:
762            device: Device object
763            uri: peer uri
764            security: Security type: SAE or PSK
765
766        Returns:
767            ssid: SSID name of the network to be configured
768            uri_id: bootstrap id
769    """
770
771    self.log.info("Starting Initiator in Configurator mode")
772
773    use_psk = False
774
775    conf = " role=configurator"
776    conf += " conf=sta-"
777
778    if security == self.DPP_TEST_SECURITY_SAE:
779      if not self.dut.droid.wifiIsWpa3SaeSupported():
780        self.log.warning("SAE not supported on device! reverting to PSK")
781        security = self.DPP_TEST_SECURITY_PSK_PASSPHRASE
782
783    ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8)
784    password = utils.rand_ascii_str(8)
785
786    if security == self.DPP_TEST_SECURITY_SAE:
787      conf += self.WPA_SUPPLICANT_SECURITY_SAE
788      if not self.sae_network_ssid is None:
789        ssid = self.sae_network_ssid
790        password = self.sae_network_password
791    elif security == self.DPP_TEST_SECURITY_PSK_PASSPHRASE:
792      conf += self.WPA_SUPPLICANT_SECURITY_PSK
793      if not self.psk_network_ssid is None:
794        ssid = self.psk_network_ssid
795        password = self.psk_network_password
796    else:
797      conf += self.WPA_SUPPLICANT_SECURITY_PSK
798      use_psk = True
799
800    self.log.debug("SSID = %s" % ssid)
801
802    ssid_encoded = binascii.hexlify(ssid.encode()).decode()
803
804    if use_psk:
805      psk = utils.rand_ascii_str(16)
806      psk_encoded = binascii.b2a_hex(psk.encode()).decode()
807      self.log.debug("PSK = %s" % psk)
808    else:
809      password_encoded = binascii.b2a_hex(password.encode()).decode()
810      self.log.debug("Password = %s" % password)
811
812    conf += " ssid=%s" % ssid_encoded
813
814    if password:  # SAE password or PSK passphrase
815      conf += " pass=%s" % password_encoded
816    else:  # PSK
817      conf += " psk=%s" % psk_encoded
818
819    cmd = "wpa_cli -iwlan0 DPP_QR_CODE '%s'" % (uri)
820    self.log.info ("Command used: %s" % cmd)
821    result = self.helper_dev.adb.shell(cmd)
822    if "FAIL" in result:
823      asserts.fail(
824          "start_initiator_configurator: Failure. Command used: %s" % cmd)
825
826    uri_id = result
827    device.log.info("peer id = %s" % result)
828
829    cmd = "wpa_cli -iwlan0 DPP_AUTH_INIT peer=%s %s " % (result, conf)
830    self.log.info("Command used: %s" % cmd)
831    result = self.helper_dev.adb.shell(cmd)
832    if "FAIL" in result:
833      asserts.fail(
834          "start_responder_configurator: Failure. Command used: %s" % cmd)
835
836    device.log.info("Started initiator in configurator mode")
837    return ssid, uri_id
838
839  def start_dpp_as_responder_enrollee(self,
840                                      security,
841                                      curve):
842    """ Test Easy Connect (DPP) as responder enrollee.
843
844                1. Enable wifi, if needed
845                2. Start DPP as Responder - Enrollee on DUT
846                3. Receive the generated URI from DUT
847                3. Start DPP as Initiator - Configurator on helper device by passing the URI
848                4. Check if configuration received successfully on DUT
849                5. Remove the configuration.
850
851        Args:
852            security: Security type, a string "SAE" or "PSK"
853            curve: cryptography curve type, a string DPP_TEST_CRYPTOGRAPHY_CURVE_XXX
854    """
855    if not self.dut.droid.wifiIsEasyConnectEnrolleeResponderModeSupported():
856      self.log.warning("Easy Connect Enrollee responder mode is not supported on device!")
857      return
858
859    wutils.wifi_toggle_state(self.dut, True)
860
861    self.log.info("Starting DPP in Enrollee-Responder mode, curve: %s" % curve)
862
863    # Start DPP as Enrollee-Responder on DUT
864    self.dut.droid.startEasyConnectAsEnrolleeResponder("DPP_RESPONDER_TESTER", curve)
865
866    network_id = 0
867
868    start_time = time.time()
869    while time.time() < start_time + self.DPP_TEST_TIMEOUT:
870      dut_event = self.dut.ed.pop_event(self.DPP_TEST_EVENT_DPP_CALLBACK,
871                                        self.DPP_TEST_TIMEOUT)
872      if dut_event[self.DPP_TEST_EVENT_DATA][
873          self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_ENROLLEE_SUCCESS:
874          self.dut.log.info("DPP Configuration received success")
875          network_id = dut_event[self.DPP_TEST_EVENT_DATA][
876              self.DPP_TEST_MESSAGE_NETWORK_ID]
877          self.dut.log.info("NetworkID: %d" % network_id)
878          break
879      if dut_event[self.DPP_TEST_EVENT_DATA][
880          self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_URI_GENERATED:
881          self.dut.log.info(
882              "Generated URI %s" %
883              dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_GENERATED_URI])
884          uri = dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_GENERATED_URI]
885
886          # Start DPP as an configurator-initiator for STA on helper device
887          result = self.start_initiator_configurator(self.helper_dev, uri, security=security)
888          continue
889      if dut_event[self.DPP_TEST_EVENT_DATA][
890          self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_PROGRESS:
891        self.dut.log.info("DPP progress event")
892        val = dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS]
893        if val == 0:
894          self.dut.log.info("DPP Authentication success")
895        elif val == 1:
896          self.dut.log.info("DPP Response pending")
897        continue
898      if dut_event[self.DPP_TEST_EVENT_DATA][
899          self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_FAILURE:
900        asserts.fail(
901            "DPP failure, status code: %s" %
902            dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS])
903        break
904      asserts.fail("Unknown message received")
905
906    # Clear all pending events.
907    self.dut.ed.clear_all_events()
908
909    # Stop initiator
910    self.stop_initiator(self.helper_dev, flush=True)
911
912    # Delete URI
913    if not result is None:
914      self.log.info("SSID: %s URI_ID: %s" % (result[0], result[1]))
915      self.del_uri(self.helper_dev, result[1])
916
917      # Check that the saved network is what we expect
918      asserts.assert_true(
919          self.check_network_config_saved(result[0], security, network_id),
920          "Could not find the expected network: %s" % result[0])
921      asserts.assert_true(
922          self.forget_network(network_id),
923          "Test network not deleted from configured networks.")
924    else:
925      asserts.fail("Failed to configure initiator")
926
927  """ Tests Begin """
928
929  @test_tracker_info(uuid="30893d51-2069-4e1c-8917-c8a840f91b59")
930  @WifiBaseTest.wifi_test_wrap
931  def test_dpp_as_initiator_configurator_with_psk_5G(self):
932    asserts.skip_if(not self.dut.droid.wifiIs5GHzBandSupported() or
933            not self.helper_dev.droid.wifiIs5GHzBandSupported(),
934            "5G not supported on at least on test device")
935    self.start_dpp_as_initiator_configurator(
936      security=self.DPP_TEST_SECURITY_PSK, responder_chan="126/149", responder_freq=5745,
937      use_mac=True)
938
939  @test_tracker_info(uuid="54d1d19a-aece-459c-b819-9d4b1ae63f77")
940  @WifiBaseTest.wifi_test_wrap
941  def test_dpp_as_initiator_configurator_with_psk_5G_broadcast(self):
942    asserts.skip_if(not self.dut.droid.wifiIs5GHzBandSupported() or
943                    not self.helper_dev.droid.wifiIs5GHzBandSupported(),
944                    "5G not supported on at least on test device")
945    self.start_dpp_as_initiator_configurator(
946      security=self.DPP_TEST_SECURITY_PSK, responder_chan="126/149", responder_freq=5745,
947      use_mac=False)
948
949  @test_tracker_info(uuid="18270a69-300c-4f54-87fd-c19073a2854e ")
950  @WifiBaseTest.wifi_test_wrap
951  def test_dpp_as_initiator_configurator_with_psk_no_chan_in_uri_listen_on_5745_broadcast(self):
952    asserts.skip_if(not self.dut.droid.wifiIs5GHzBandSupported() or
953                    not self.helper_dev.droid.wifiIs5GHzBandSupported(),
954                    "5G not supported on at least on test device")
955    self.start_dpp_as_initiator_configurator(
956      security=self.DPP_TEST_SECURITY_PSK, responder_chan=None, responder_freq=5745, use_mac=False)
957
958  @test_tracker_info(uuid="fbdd687c-954a-400b-9da3-2d17e28b0798")
959  @WifiBaseTest.wifi_test_wrap
960  def test_dpp_as_initiator_configurator_with_psk_no_chan_in_uri_listen_on_5745(self):
961    asserts.skip_if(not self.dut.droid.wifiIs5GHzBandSupported() or
962                    not self.helper_dev.droid.wifiIs5GHzBandSupported(),
963                    "5G not supported on at least on test device")
964    self.start_dpp_as_initiator_configurator(
965      security=self.DPP_TEST_SECURITY_PSK, responder_chan=None, responder_freq=5745, use_mac=True)
966
967  @test_tracker_info(uuid="570f499f-ab12-4405-af14-c9ed36da2e01")
968  @WifiBaseTest.wifi_test_wrap
969  def test_dpp_as_initiator_configurator_with_psk_no_chan_in_uri_listen_on_2462_broadcast(self):
970    self.start_dpp_as_initiator_configurator(
971      security=self.DPP_TEST_SECURITY_PSK, responder_chan=None, responder_freq=2462, use_mac=False)
972
973  @test_tracker_info(uuid="e1f083e0-0878-4c49-8ac5-d7c6bba24625")
974  @WifiBaseTest.wifi_test_wrap
975  def test_dpp_as_initiator_configurator_with_psk_no_chan_in_uri_listen_on_2462(self):
976    self.start_dpp_as_initiator_configurator(
977      security=self.DPP_TEST_SECURITY_PSK, responder_chan=None, responder_freq=2462, use_mac=True)
978
979  @test_tracker_info(uuid="d2a526f5-4269-493d-bd79-4e6d1b7b00f0")
980  @WifiBaseTest.wifi_test_wrap
981  def test_dpp_as_initiator_configurator_with_psk(self):
982    self.start_dpp_as_initiator_configurator(
983        security=self.DPP_TEST_SECURITY_PSK, use_mac=True)
984
985  @test_tracker_info(uuid="6ead218c-222b-45b8-8aad-fe7d883ed631")
986  @WifiBaseTest.wifi_test_wrap
987  def test_dpp_as_initiator_configurator_with_sae(self):
988    self.start_dpp_as_initiator_configurator(
989        security=self.DPP_TEST_SECURITY_SAE, use_mac=True)
990
991  @test_tracker_info(uuid="1686adb5-1b3c-4e6d-a969-6b007bdd990d")
992  @WifiBaseTest.wifi_test_wrap
993  def test_dpp_as_initiator_configurator_with_psk_passphrase(self):
994    self.start_dpp_as_initiator_configurator(
995        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE, use_mac=True)
996
997  @test_tracker_info(uuid="3958feb5-1a0c-4487-9741-ac06f04c55a2")
998  @WifiBaseTest.wifi_test_wrap
999  def test_dpp_as_initiator_configurator_with_sae_broadcast(self):
1000    self.start_dpp_as_initiator_configurator(
1001        security=self.DPP_TEST_SECURITY_SAE, use_mac=False)
1002
1003  @test_tracker_info(uuid="fe6d66f5-73a1-46e9-8f49-73b8f332cc8c")
1004  @WifiBaseTest.wifi_test_wrap
1005  def test_dpp_as_initiator_configurator_with_psk_passphrase_broadcast(self):
1006    self.start_dpp_as_initiator_configurator(
1007        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE, use_mac=False)
1008
1009  @test_tracker_info(uuid="9edd372d-e2f1-4545-8d04-6a1636fcbc4b")
1010  @WifiBaseTest.wifi_test_wrap
1011  def test_dpp_as_initiator_configurator_with_sae_for_ap(self):
1012    self.start_dpp_as_initiator_configurator(
1013        security=self.DPP_TEST_SECURITY_SAE,
1014        use_mac=True,
1015        net_role=self.DPP_TEST_NETWORK_ROLE_AP)
1016
1017  @test_tracker_info(uuid="e9eec912-d665-4926-beac-859cb13dc17b")
1018  @WifiBaseTest.wifi_test_wrap
1019  def test_dpp_as_initiator_configurator_with_psk_passphrase_for_ap(self):
1020    self.start_dpp_as_initiator_configurator(
1021        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1022        use_mac=True,
1023        net_role=self.DPP_TEST_NETWORK_ROLE_AP)
1024
1025  @test_tracker_info(uuid="8055694f-606f-41dd-9826-3ea1e9b007f8")
1026  @WifiBaseTest.wifi_test_wrap
1027  def test_dpp_as_initiator_enrollee_with_sae(self):
1028    self.start_dpp_as_initiator_enrollee(
1029        security=self.DPP_TEST_SECURITY_SAE, use_mac=True)
1030
1031  @test_tracker_info(uuid="c1e9f605-b5c0-4e53-8a08-1b0087a667fa")
1032  @WifiBaseTest.wifi_test_wrap
1033  def test_dpp_as_initiator_enrollee_with_psk_passphrase(self):
1034    self.start_dpp_as_initiator_enrollee(
1035        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE, use_mac=True)
1036
1037  @test_tracker_info(uuid="1d7f30ad-2f9a-427a-8059-651dc8827ae2")
1038  @WifiBaseTest.wifi_test_wrap
1039  def test_dpp_as_initiator_enrollee_with_sae_broadcast(self):
1040    self.start_dpp_as_initiator_enrollee(
1041        security=self.DPP_TEST_SECURITY_SAE, use_mac=False)
1042
1043  @test_tracker_info(uuid="0cfc2645-600e-4f2b-ab5c-fcee6d363a9a")
1044  @WifiBaseTest.wifi_test_wrap
1045  def test_dpp_as_initiator_enrollee_with_psk_passphrase_broadcast(self):
1046    self.start_dpp_as_initiator_enrollee(
1047        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE, use_mac=False)
1048
1049  @test_tracker_info(uuid="2e26b248-65dd-41f6-977b-e223d72b2de9")
1050  @WifiBaseTest.wifi_test_wrap
1051  def test_start_dpp_as_initiator_enrollee_receive_invalid_config(self):
1052    self.start_dpp_as_initiator_enrollee(
1053        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1054        use_mac=True,
1055        invalid_config=True)
1056
1057  @test_tracker_info(uuid="ed189661-d1c1-4626-9f01-3b7bb8a417fe")
1058  @WifiBaseTest.wifi_test_wrap
1059  def test_dpp_as_initiator_configurator_fail_authentication(self):
1060    self.start_dpp_as_initiator_configurator(
1061        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1062        use_mac=True,
1063        fail_authentication=True)
1064
1065  @test_tracker_info(uuid="5a8c6587-fbb4-4a27-9cba-af6f8935833a")
1066  @WifiBaseTest.wifi_test_wrap
1067  def test_dpp_as_initiator_configurator_fail_unicast_timeout(self):
1068    self.start_dpp_as_initiator_configurator(
1069        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1070        use_mac=True,
1071        cause_timeout=True)
1072
1073  @test_tracker_info(uuid="b12353ac-1a04-4036-81a4-2d2d0c653dbb")
1074  @WifiBaseTest.wifi_test_wrap
1075  def test_dpp_as_initiator_configurator_fail_broadcast_timeout(self):
1076    self.start_dpp_as_initiator_configurator(
1077        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1078        use_mac=False,
1079        cause_timeout=True)
1080
1081  @test_tracker_info(uuid="eeff91be-09ce-4a33-8b4f-ece40eb51c76")
1082  @WifiBaseTest.wifi_test_wrap
1083  def test_dpp_as_initiator_configurator_invalid_uri(self):
1084    self.start_dpp_as_initiator_configurator(
1085        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1086        use_mac=True,
1087        invalid_uri=True)
1088
1089  @test_tracker_info(uuid="1fa25f58-0d0e-40bd-8714-ab78957514d9")
1090  @WifiBaseTest.wifi_test_wrap
1091  def test_start_dpp_as_initiator_enrollee_fail_timeout(self):
1092    self.start_dpp_as_initiator_enrollee(
1093        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1094        use_mac=True,
1095        cause_timeout=True)
1096
1097  @test_tracker_info(uuid="23601af8-118e-4ba8-89e3-5da2e37bbd7d")
1098  def test_dpp_as_initiator_configurator_fail_r2_no_ap(self):
1099    asserts.skip_if(self.dpp_r1_test_only == "True",
1100                    "DPP R1 test, skipping this test for DPP R2 only")
1101    self.start_dpp_as_initiator_configurator(
1102      security=self.DPP_TEST_SECURITY_PSK, use_mac=True, r2_no_ap=True)
1103
1104  @test_tracker_info(uuid="7f9756d3-f28f-498e-8dcf-ac3816303998")
1105  def test_dpp_as_initiator_configurator_fail_r2_auth_error(self):
1106    asserts.skip_if(self.dpp_r1_test_only == "True",
1107                    "DPP R1 test, skipping this test for DPP R2 only")
1108    self.start_dpp_as_initiator_configurator(
1109      security=self.DPP_TEST_SECURITY_PSK, use_mac=True, r2_auth_error=True)
1110
1111  @test_tracker_info(uuid="608c8d47-b9ed-4668-a438-cf5035d27818")
1112  @WifiBaseTest.wifi_test_wrap
1113  def test_dpp_as_responder_enrollee_with_psk_passphrase_curve_prime256v1(self):
1114    self.start_dpp_as_responder_enrollee(
1115        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1116        curve=self.DPP_TEST_CRYPTOGRAPHY_CURVE_PRIME256V1)
1117
1118  @test_tracker_info(uuid="51d47a54-e19e-4513-b6e8-161e786db0b0")
1119  @WifiBaseTest.wifi_test_wrap
1120  def test_dpp_as_responder_enrollee_with_sae_curve_prime256v1(self):
1121    self.start_dpp_as_responder_enrollee(
1122        security=self.DPP_TEST_SECURITY_SAE,
1123        curve=self.DPP_TEST_CRYPTOGRAPHY_CURVE_PRIME256V1)
1124
1125  @test_tracker_info(uuid="f4ede61b-2cee-4ff0-b9d6-3dca9245021b")
1126  @WifiBaseTest.wifi_test_wrap
1127  def test_dpp_as_responder_enrollee_with_psk_passphrase_curve_secp384r1(self):
1128    self.start_dpp_as_responder_enrollee(
1129        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1130        curve=self.DPP_TEST_CRYPTOGRAPHY_CURVE_SECP384R1)
1131
1132  @test_tracker_info(uuid="57855cba-9cf2-4837-ae77-3dc78bf8b3b5")
1133  @WifiBaseTest.wifi_test_wrap
1134  def test_dpp_as_responder_enrollee_with_sae_curve_secp384r1(self):
1135    self.start_dpp_as_responder_enrollee(
1136        security=self.DPP_TEST_SECURITY_SAE,
1137        curve=self.DPP_TEST_CRYPTOGRAPHY_CURVE_SECP384R1)
1138
1139  @test_tracker_info(uuid="eb9c22a0-f17e-4985-b1b0-fdd3871d29b7")
1140  @WifiBaseTest.wifi_test_wrap
1141  def test_dpp_as_responder_enrollee_with_psk_passphrase_curve_secp521r1(self):
1142    self.start_dpp_as_responder_enrollee(
1143        security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
1144        curve=self.DPP_TEST_CRYPTOGRAPHY_CURVE_SECP521R1)
1145
1146  @test_tracker_info(uuid="2677e549-a37a-42f6-8fab-c9a68fcf15f9")
1147  @WifiBaseTest.wifi_test_wrap
1148  def test_dpp_as_responder_enrollee_with_sae_curve_secp521r1(self):
1149    self.start_dpp_as_responder_enrollee(
1150        security=self.DPP_TEST_SECURITY_SAE,
1151        curve=self.DPP_TEST_CRYPTOGRAPHY_CURVE_SECP521R1)
1152
1153""" Tests End """
1154