def test_ap_wpa2_tdls_bssid_mismatch(dev, apdev): """TDLS failure due to BSSID mismatch""" try: ssid = "test-wpa2-psk" passphrase = "12345678" params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params['bridge'] = 'ap-br0' hapd = hostapd.add_ap(apdev[0], params) hostapd.add_ap(apdev[1], params) wlantest_setup(hapd) subprocess.call(['brctl', 'setfd', 'ap-br0', '0']) subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'up']) dev[0].connect(ssid, psk=passphrase, scan_freq="2412", bssid=apdev[0]['bssid']) dev[1].connect(ssid, psk=passphrase, scan_freq="2412", bssid=apdev[1]['bssid']) hwsim_utils.test_connectivity_sta(dev[0], dev[1]) hwsim_utils.test_connectivity_iface(dev[0], hapd, "ap-br0") hwsim_utils.test_connectivity_iface(dev[1], hapd, "ap-br0") addr0 = dev[0].p2p_interface_addr() dev[1].tdls_setup(addr0) time.sleep(1) hwsim_utils.test_connectivity_sta(dev[0], dev[1]) finally: subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down']) subprocess.call(['brctl', 'delbr', 'ap-br0'])
def test_peerkey_pairwise_mismatch(dev, apdev): """RSN TKIP+CCMP AP and PeerKey between two STAs using different ciphers""" skip_with_fips(dev[0]) wt = Wlantest() wt.flush() wt.add_passphrase("12345678") ssid = "test-peerkey" passphrase = "12345678" params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params['peerkey'] = "1" params['rsn_pairwise'] = "TKIP CCMP" hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True, pairwise="CCMP") dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True, pairwise="TKIP") hwsim_utils.test_connectivity_sta(dev[0], dev[1]) dev[0].request("STKSTART " + dev[1].p2p_interface_addr()) time.sleep(0.5) dev[1].request("STKSTART " + dev[0].p2p_interface_addr()) time.sleep(0.5)
def test_ap_wpa2_bridge_fdb(dev, apdev): """Bridge FDB entry removal""" try: ssid = "test-wpa2-psk" passphrase = "12345678" params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params['bridge'] = 'ap-br0' hostapd.add_ap(apdev[0]['ifname'], params) subprocess.call(['sudo', 'brctl', 'setfd', 'ap-br0', '0']) subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'ap-br0', 'up']) dev[0].connect(ssid, psk=passphrase, scan_freq="2412", bssid=apdev[0]['bssid']) dev[1].connect(ssid, psk=passphrase, scan_freq="2412", bssid=apdev[0]['bssid']) addr0 = dev[0].p2p_interface_addr() hwsim_utils.test_connectivity_sta(dev[0], dev[1]) cmd = subprocess.Popen(['brctl', 'showmacs', 'ap-br0'], stdout=subprocess.PIPE) macs1 = cmd.stdout.read() dev[0].request("DISCONNECT") dev[1].request("DISCONNECT") time.sleep(1) cmd = subprocess.Popen(['brctl', 'showmacs', 'ap-br0'], stdout=subprocess.PIPE) macs2 = cmd.stdout.read() addr1 = dev[1].p2p_interface_addr() if addr0 not in macs1 or addr1 not in macs1: raise Exception("Bridge FDB entry missing") if addr0 in macs2 or addr1 in macs2: raise Exception("Bridge FDB entry was not removed") finally: subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'ap-br0', 'down']) subprocess.call(['sudo', 'brctl', 'delbr', 'ap-br0'])
def test_peerkey_pairwise_mismatch(dev, apdev): """RSN TKIP+CCMP AP and PeerKey between two STAs using different ciphers""" skip_with_fips(dev[0]) ssid = "test-peerkey" passphrase = "12345678" params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params['peerkey'] = "1" params['rsn_pairwise'] = "TKIP CCMP" hapd = hostapd.add_ap(apdev[0], params) Wlantest.setup(hapd) wt = Wlantest() wt.flush() wt.add_passphrase("12345678") dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True, pairwise="CCMP") dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True, pairwise="TKIP") hwsim_utils.test_connectivity_sta(dev[0], dev[1]) dev[0].request("STKSTART " + dev[1].p2p_interface_addr()) time.sleep(0.5) dev[1].request("STKSTART " + dev[0].p2p_interface_addr()) time.sleep(0.5)
def test_ap_wps_er_add_enrollee_pbc(dev, apdev): """WPS ER connected to AP and adding a new enrollee using PBC""" ssid = "wps-er-add-enrollee-pbc" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0]['ifname'], { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", "device_name": "Wireless AP", "manufacturer": "Company", "model_name": "WAP", "model_number": "123", "serial_number": "12345", "device_type": "6-0050F204-1", "os_version": "01020300", "config_methods": "label push_button", "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"}) logger.info("Learn AP configuration") dev[0].dump_monitor() dev[0].request("SET ignore_old_scan_res 1") dev[0].wps_reg(apdev[0]['bssid'], ap_pin) status = dev[0].get_status() if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: raise Exception("Not fully connected") logger.info("Start ER") dev[0].request("WPS_ER_START ifname=lo") ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15) if ev is None: raise Exception("AP discovery timed out") if ap_uuid not in ev: raise Exception("Expected AP UUID not found") logger.info("Use learned network configuration on ER") dev[0].request("WPS_ER_SET_CONFIG " + ap_uuid + " 0") logger.info("Add Enrollee using ER and PBC") dev[0].dump_monitor() enrollee = dev[1].p2p_interface_addr() dev[1].request("SET ignore_old_scan_res 1") dev[1].dump_monitor() dev[1].request("WPS_PBC") ev = dev[0].wait_event(["WPS-ER-ENROLLEE-ADD"], timeout=15) if ev is None: raise Exception("Enrollee discovery timed out") if enrollee not in ev: raise Exception("Expected Enrollee not found") dev[0].request("WPS_ER_PBC " + enrollee) ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=15) if ev is None: raise Exception("Enrollee did not report success") ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) if ev is None: raise Exception("Association with the AP timed out") ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15) if ev is None: raise Exception("WPS ER did not report success") hwsim_utils.test_connectivity_sta(dev[0], dev[1])
def tdls_check_ap(sta0, sta1, bssid, addr0, addr1): wt = Wlantest() wt.tdls_clear(bssid, addr0, addr1) hwsim_utils.test_connectivity_sta(sta0, sta1) [dl,inv_dl,ap,inv_ap] = wlantest_tdls_packet_counters(bssid, addr0, addr1) if dl > 0: raise Exception("Unexpected frames through direct link") if inv_dl > 0: raise Exception("Invalid frames through direct link") if ap == 0: raise Exception("No valid frames through AP path") if inv_ap > 0: raise Exception("Invalid frames through AP path")
def tdls_check_ap(sta0, sta1, bssid, addr0, addr1): wt = Wlantest() wt.tdls_clear(bssid, addr0, addr1) hwsim_utils.test_connectivity_sta(sta0, sta1) [dl, inv_dl, ap, inv_ap] = wlantest_tdls_packet_counters(bssid, addr0, addr1) if dl > 0: raise Exception("Unexpected frames through direct link") if inv_dl > 0: raise Exception("Invalid frames through direct link") if ap == 0: raise Exception("No valid frames through AP path") if inv_ap > 0: raise Exception("Invalid frames through AP path")
def test_peerkey_unknown_peer(dev, apdev): """RSN AP and PeerKey attempt with unknown peer""" ssid = "test-peerkey" passphrase = "12345678" params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params['peerkey'] = "1" hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) hwsim_utils.test_connectivity_sta(dev[0], dev[1]) dev[0].request("STKSTART " + dev[2].p2p_interface_addr()) time.sleep(0.5)
def test_peerkey(dev, apdev): """RSN AP and PeerKey between two STAs""" ssid = "test-peerkey" passphrase = "12345678" params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params['peerkey'] = "1" hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) hwsim_utils.test_connectivity_sta(dev[0], dev[1]) dev[0].request("STKSTART " + dev[1].p2p_interface_addr()) time.sleep(0.5)
def test_peerkey_sniffer_check(dev, apdev, params): """RSN AP and PeerKey between two STAs with sniffer check""" ssid = "test-peerkey" passphrase = "12345678" hparams = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) hparams['peerkey'] = "1" hapd = hostapd.add_ap(apdev[0], hparams) Wlantest.setup(hapd) wt = Wlantest() wt.flush() wt.add_passphrase("12345678") dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) hwsim_utils.test_connectivity_sta(dev[0], dev[1]) dev[0].request("STKSTART " + dev[1].p2p_interface_addr()) time.sleep(1) # NOTE: Actual use of the direct link (DLS) is not supported in # mac80211_hwsim, so this operation fails at setting the keys after # successfully completed 4-way handshake. This test case does allow the # key negotiation part to be tested for coverage, though. Use sniffer to # verify that all the SMK and STK handshake messages were transmitted. bssid = hapd.own_addr() addr0 = dev[0].own_addr() addr1 = dev[1].own_addr() # Wireshark renamed the EAPOL-Key key_info field, so need to try both the # new and the old name to work with both versions. try_other = False try: out = run_tshark( os.path.join(params['logdir'], "hwsim0.pcapng"), "eapol.type == 3", display=["wlan.sa", "wlan.da", "wlan_rsna_eapol.keydes.key_info"]) except Exception, e: if "Unknown tshark field" in str(e): try_other = True pass else: raise
def test_peerkey_sniffer_check(dev, apdev, params): """RSN AP and PeerKey between two STAs with sniffer check""" ssid = "test-peerkey" passphrase = "12345678" hparams = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) hparams['peerkey'] = "1" hapd = hostapd.add_ap(apdev[0], hparams) Wlantest.setup(hapd) wt = Wlantest() wt.flush() wt.add_passphrase("12345678") dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) hwsim_utils.test_connectivity_sta(dev[0], dev[1]) dev[0].request("STKSTART " + dev[1].p2p_interface_addr()) time.sleep(1) # NOTE: Actual use of the direct link (DLS) is not supported in # mac80211_hwsim, so this operation fails at setting the keys after # successfully completed 4-way handshake. This test case does allow the # key negotiation part to be tested for coverage, though. Use sniffer to # verify that all the SMK and STK handshake messages were transmitted. bssid = hapd.own_addr() addr0 = dev[0].own_addr() addr1 = dev[1].own_addr() # Wireshark renamed the EAPOL-Key key_info field, so need to try both the # new and the old name to work with both versions. try_other = False try: out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), "eapol.type == 3", display=["wlan.sa", "wlan.da", "wlan_rsna_eapol.keydes.key_info"]) except Exception, e: if "Unknown tshark field" in str(e): try_other = True pass else: raise
def connectivity(dev, hapd): hwsim_utils.test_connectivity_sta(dev[0], dev[1]) hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[1], hapd)
def test_peerkey_sniffer_check(dev, apdev, params): """RSN AP and PeerKey between two STAs with sniffer check""" ssid = "test-peerkey" passphrase = "12345678" hparams = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) hparams['peerkey'] = "1" hapd = hostapd.add_ap(apdev[0], hparams) Wlantest.setup(hapd) wt = Wlantest() wt.flush() wt.add_passphrase("12345678") dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) hwsim_utils.test_connectivity_sta(dev[0], dev[1]) dev[0].request("STKSTART " + dev[1].p2p_interface_addr()) time.sleep(1) # NOTE: Actual use of the direct link (DLS) is not supported in # mac80211_hwsim, so this operation fails at setting the keys after # successfully completed 4-way handshake. This test case does allow the # key negotiation part to be tested for coverage, though. Use sniffer to # verify that all the SMK and STK handshake messages were transmitted. bssid = hapd.own_addr() addr0 = dev[0].own_addr() addr1 = dev[1].own_addr() out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), "eapol.type == 3", display=["wlan.sa", "wlan.da", "eapol.keydes.key_info"]) smk = [ False, False, False, False, False ] stk = [ False, False, False, False ] for pkt in out.splitlines(): sa, da, key_info = pkt.split('\t') key_info = int(key_info, 16) if sa == addr0 and da == bssid and key_info == 0x2b02: # Initiator -> AP: MIC+Secure+Request+SMK = SMK 1 smk[0] = True elif sa == bssid and da == addr1 and key_info == 0x2382: # AP -> Responder: ACK+MIC+Secure+SMK = SMK 2 smk[1] = True elif sa == addr1 and da == bssid and key_info == 0x2302: # Responder -> AP: MIC+Secure+SMK = SMK 3 smk[2] = True elif sa == bssid and da == addr1 and key_info == 0x3342: # AP -> Responder: Install+MIC+Secure+EncrKeyData+SMK = SMK 4 smk[3] = True elif sa == bssid and da == addr0 and key_info == 0x3302: # AP -> Initiator: MIC+Secure+EncrKeyData+SMK = SMK 5 smk[4] = True elif sa == addr0 and da == addr1 and key_info == 0x008a: # Initiator -> Responder: Pairwise+ACK = STK 1 stk[0] = True elif sa == addr1 and da == addr0 and key_info == 0x010a: # Responder -> Initiator: Pairwise+MIC = STK 2 stk[1] = True elif sa == addr0 and da == addr1 and key_info == 0x038a: # Initiator -> Responder: Pairwise+ACK+MIC+Secure = STK 3 stk[2] = True elif sa == addr1 and da == addr0 and key_info == 0x030a: # Responder -> Initiator: Pairwise+MIC+Secure = STK 4 stk[3] = True logger.info("Seen SMK messages: " + str(smk)) logger.info("Seen STK messages: " + str(stk)) if False in smk: raise Exception("Missing SMK message: " + str(smk)) if False in stk: raise Exception("Missing STK message: " + str(stk))
def test_ap_wps_er_add_enrollee(dev, apdev): """WPS ER configuring AP and adding a new enrollee using PIN""" ssid = "wps-er-add-enrollee" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0]['ifname'], { "ssid": ssid, "eap_server": "1", "wps_state": "1", "device_name": "Wireless AP", "manufacturer": "Company", "model_name": "WAP", "model_number": "123", "serial_number": "12345", "device_type": "6-0050F204-1", "os_version": "01020300", "config_methods": "label push_button", "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"}) logger.info("WPS configuration step") new_passphrase = "1234567890" dev[0].dump_monitor() dev[0].wps_reg(apdev[0]['bssid'], ap_pin, ssid, "WPA2PSK", "CCMP", new_passphrase) status = dev[0].get_status() if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: raise Exception("Not fully connected") if status['ssid'] != ssid: raise Exception("Unexpected SSID") if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP': raise Exception("Unexpected encryption configuration") if status['key_mgmt'] != 'WPA2-PSK': raise Exception("Unexpected key_mgmt") logger.info("Start ER") dev[0].request("WPS_ER_START ifname=lo") ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15) if ev is None: raise Exception("AP discovery timed out") if ap_uuid not in ev: raise Exception("Expected AP UUID not found") logger.info("Learn AP configuration through UPnP") dev[0].dump_monitor() dev[0].request("WPS_ER_LEARN " + ap_uuid + " " + ap_pin) ev = dev[0].wait_event(["WPS-ER-AP-SETTINGS"], timeout=15) if ev is None: raise Exception("AP learn timed out") if ap_uuid not in ev: raise Exception("Expected AP UUID not in settings") if "ssid=" + ssid not in ev: raise Exception("Expected SSID not in settings") if "key=" + new_passphrase not in ev: raise Exception("Expected passphrase not in settings") logger.info("Add Enrollee using ER") pin = dev[1].wps_read_pin() dev[0].dump_monitor() dev[0].request("WPS_ER_PIN any " + pin + " " + dev[1].p2p_interface_addr()) dev[1].dump_monitor() dev[1].request("WPS_PIN any " + pin) ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=30) if ev is None: raise Exception("Enrollee did not report success") ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) if ev is None: raise Exception("Association with the AP timed out") ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15) if ev is None: raise Exception("WPS ER did not report success") hwsim_utils.test_connectivity_sta(dev[0], dev[1]) logger.info("Verify registrar selection behavior") dev[0].request("WPS_ER_PIN any " + pin + " " + dev[1].p2p_interface_addr()) dev[1].request("DISCONNECT") dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"]) dev[1].scan(freq="2412") bss = dev[1].get_bss(apdev[0]['bssid']) if "[WPS-AUTH]" not in bss['flags']: raise Exception("WPS-AUTH flag missing") logger.info("Stop ER") dev[0].dump_monitor() dev[0].request("WPS_ER_STOP") ev = dev[0].wait_event(["WPS-ER-AP-REMOVE"]) if ev is None: raise Exception("WPS ER unsubscription timed out") dev[1].scan(freq="2412") bss = dev[1].get_bss(apdev[0]['bssid']) if "[WPS-AUTH]" in bss['flags']: raise Exception("WPS-AUTH flag not removed")
def check_connectivity(sta0, sta1, hapd): hwsim_utils.test_connectivity_sta(sta0, sta1) hwsim_utils.test_connectivity(sta0, hapd) hwsim_utils.test_connectivity(sta1, hapd)
def test_ap_wps_er_add_enrollee_pbc(dev, apdev): """WPS ER connected to AP and adding a new enrollee using PBC""" ssid = "wps-er-add-enrollee-pbc" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0]['ifname'], { "ssid": ssid, "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", "device_name": "Wireless AP", "manufacturer": "Company", "model_name": "WAP", "model_number": "123", "serial_number": "12345", "device_type": "6-0050F204-1", "os_version": "01020300", "config_methods": "label push_button", "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"}) logger.info("Learn AP configuration") dev[0].dump_monitor() dev[0].wps_reg(apdev[0]['bssid'], ap_pin) status = dev[0].get_status() if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: raise Exception("Not fully connected") logger.info("Start ER") dev[0].request("WPS_ER_START ifname=lo") ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15) if ev is None: raise Exception("AP discovery timed out") if ap_uuid not in ev: raise Exception("Expected AP UUID not found") logger.info("Use learned network configuration on ER") dev[0].request("WPS_ER_SET_CONFIG " + ap_uuid + " 0") logger.info("Add Enrollee using ER and PBC") dev[0].dump_monitor() enrollee = dev[1].p2p_interface_addr() dev[1].dump_monitor() dev[1].request("WPS_PBC") for i in range(0, 2): ev = dev[0].wait_event(["WPS-ER-ENROLLEE-ADD"], timeout=15) if ev is None: raise Exception("Enrollee discovery timed out") if enrollee in ev: break if i == 1: raise Exception("Expected Enrollee not found") dev[0].request("WPS_ER_PBC " + enrollee) ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=15) if ev is None: raise Exception("Enrollee did not report success") ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) if ev is None: raise Exception("Association with the AP timed out") ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15) if ev is None: raise Exception("WPS ER did not report success") hwsim_utils.test_connectivity_sta(dev[0], dev[1]) # verify BSSID selection of the AP instead of UUID if "FAIL" in dev[0].request("WPS_ER_SET_CONFIG " + apdev[0]['bssid'] + " 0"): raise Exception("Could not select AP based on BSSID")
def connectivity(dev, ap_ifname): hwsim_utils.test_connectivity_sta(dev[0], dev[1]) hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname) hwsim_utils.test_connectivity(dev[1].ifname, ap_ifname)
def check_connectivity(sta0, sta1, ap): hwsim_utils.test_connectivity_sta(sta0, sta1) hwsim_utils.test_connectivity(sta0.ifname, ap['ifname']) hwsim_utils.test_connectivity(sta1.ifname, ap['ifname'])
def test_ap_wps_er_add_enrollee(dev, apdev): """WPS ER configuring AP and adding a new enrollee using PIN""" ssid = "wps-er-add-enrollee" ap_pin = "12345670" ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" hostapd.add_ap(apdev[0]['ifname'], { "ssid": ssid, "eap_server": "1", "wps_state": "1", "device_name": "Wireless AP", "manufacturer": "Company", "model_name": "WAP", "model_number": "123", "serial_number": "12345", "device_type": "6-0050F204-1", "os_version": "01020300", "config_methods": "label push_button", "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"}) logger.info("WPS configuration step") new_passphrase = "1234567890" dev[0].dump_monitor() dev[0].request("SET ignore_old_scan_res 1") dev[0].wps_reg(apdev[0]['bssid'], ap_pin, ssid, "WPA2PSK", "CCMP", new_passphrase) status = dev[0].get_status() if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: raise Exception("Not fully connected") if status['ssid'] != ssid: raise Exception("Unexpected SSID") if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP': raise Exception("Unexpected encryption configuration") if status['key_mgmt'] != 'WPA2-PSK': raise Exception("Unexpected key_mgmt") logger.info("Start ER") dev[0].request("WPS_ER_START ifname=lo") ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15) if ev is None: raise Exception("AP discovery timed out") if ap_uuid not in ev: raise Exception("Expected AP UUID not found") logger.info("Learn AP configuration through UPnP") dev[0].dump_monitor() dev[0].request("WPS_ER_LEARN " + ap_uuid + " " + ap_pin) ev = dev[0].wait_event(["WPS-ER-AP-SETTINGS"], timeout=15) if ev is None: raise Exception("AP learn timed out") if ap_uuid not in ev: raise Exception("Expected AP UUID not in settings") if "ssid=" + ssid not in ev: raise Exception("Expected SSID not in settings") if "key=" + new_passphrase not in ev: raise Exception("Expected passphrase not in settings") logger.info("Add Enrollee using ER") pin = dev[1].wps_read_pin() dev[0].dump_monitor() dev[0].request("WPS_ER_PIN any " + pin + " " + dev[1].p2p_interface_addr()) dev[1].request("SET ignore_old_scan_res 1") dev[1].dump_monitor() dev[1].request("WPS_PIN any " + pin) ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=30) if ev is None: raise Exception("Enrollee did not report success") ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) if ev is None: raise Exception("Association with the AP timed out") ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15) if ev is None: raise Exception("WPS ER did not report success") hwsim_utils.test_connectivity_sta(dev[0], dev[1])