Signed-off-by: Masashi Honma <masashi.honma@xxxxxxxxx> --- tests/hwsim/test_ap_ft.py | 86 +++++++++++++++++++------------------- tests/hwsim/test_ap_psk.py | 7 +++- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/tests/hwsim/test_ap_ft.py b/tests/hwsim/test_ap_ft.py index c1c46655e..a723ff9a2 100644 --- a/tests/hwsim/test_ap_ft.py +++ b/tests/hwsim/test_ap_ft.py @@ -753,22 +753,22 @@ def test_ap_ft_over_ds_unexpected(dev, apdev): hapd1ap.mgmt_tx(msg) logger.info("No R0KH-ID subelem in FTIE") - snonce = binascii.hexlify(req['payload'][111:111+32]) + snonce = binascii.hexlify(req['payload'][111:111+32]).decode() msg['payload'] = binascii.unhexlify("0602" + addrs + "00003603a1b20137520000" + "00000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + snonce) hapd1ap.mgmt_tx(msg) logger.info("No R0KH-ID subelem mismatch in FTIE") - snonce = binascii.hexlify(req['payload'][111:111+32]) + snonce = binascii.hexlify(req['payload'][111:111+32]).decode() msg['payload'] = binascii.unhexlify("0602" + addrs + "00003603a1b201375e0000" + "00000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + snonce + "030a11223344556677889900") hapd1ap.mgmt_tx(msg) logger.info("No R1KH-ID subelem in FTIE") - r0khid = binascii.hexlify(req['payload'][145:145+10]) + r0khid = binascii.hexlify(req['payload'][145:145+10]).decode() msg['payload'] = binascii.unhexlify("0602" + addrs + "00003603a1b201375e0000" + "00000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + snonce + "030a" + r0khid) hapd1ap.mgmt_tx(msg) logger.info("No RSNE") - r0khid = binascii.hexlify(req['payload'][145:145+10]) + r0khid = binascii.hexlify(req['payload'][145:145+10]).decode() msg['payload'] = binascii.unhexlify("0602" + addrs + "00003603a1b20137660000" + "00000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + snonce + "030a" + r0khid + "0106000102030405") hapd1ap.mgmt_tx(msg) @@ -2061,82 +2061,82 @@ def test_ap_ft_rrb(dev, apdev): _dst_ll = binascii.unhexlify(apdev[0]['bssid'].replace(':','')) _src_ll = binascii.unhexlify(dev[0].own_addr().replace(':','')) - proto = '\x89\x0d' + proto = b'\x89\x0d' ehdr = _dst_ll + _src_ll + proto # Too short RRB frame - pkt = ehdr + '\x01' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # RRB discarded frame wikth unrecognized type - pkt = ehdr + '\x02' + '\x02' + '\x01\x00' + _src_ll - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x02' + b'\x02' + b'\x01\x00' + _src_ll + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # RRB frame too short for action frame - pkt = ehdr + '\x01' + '\x02' + '\x01\x00' + _src_ll - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\x02' + b'\x01\x00' + _src_ll + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # Too short RRB frame (not enough room for Action Frame body) - pkt = ehdr + '\x01' + '\x02' + '\x00\x00' + _src_ll - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\x02' + b'\x00\x00' + _src_ll + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # Unexpected Action frame category - pkt = ehdr + '\x01' + '\x02' + '\x0e\x00' + _src_ll + '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\x02' + b'\x0e\x00' + _src_ll + b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # Unexpected Action in RRB Request - pkt = ehdr + '\x01' + '\x00' + '\x0e\x00' + _src_ll + '\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\x00' + b'\x0e\x00' + _src_ll + b'\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # Target AP address in RRB Request does not match with own address - pkt = ehdr + '\x01' + '\x00' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\x00' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # Not enough room for status code in RRB Response - pkt = ehdr + '\x01' + '\x01' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\x01' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # RRB discarded frame with unknown packet_type - pkt = ehdr + '\x01' + '\x02' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\x02' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # RRB Response with non-zero status code; no STA match - pkt = ehdr + '\x01' + '\x01' + '\x10\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + '\xff\xff' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\x01' + b'\x10\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + b'\xff\xff' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # RRB Response with zero status code and extra data; STA match - pkt = ehdr + '\x01' + '\x01' + '\x11\x00' + _src_ll + '\x06\x01' + _src_ll + '\x00\x00\x00\x00\x00\x00' + '\x00\x00' + '\x00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\x01' + b'\x11\x00' + _src_ll + b'\x06\x01' + _src_ll + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00' + b'\x00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # Too short PMK-R1 pull - pkt = ehdr + '\x01' + '\xc8' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\xc8' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # Too short PMK-R1 resp - pkt = ehdr + '\x01' + '\xc9' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\xc9' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # Too short PMK-R1 push - pkt = ehdr + '\x01' + '\xca' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\xca' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") # No matching R0KH address found for PMK-R0 pull response - pkt = ehdr + '\x01' + '\xc9' + '\x5a\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + 76*'\00' - if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt)): + pkt = ehdr + b'\x01' + b'\xc9' + b'\x5a\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + 76 * b'\00' + if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()): raise Exception("DATA_TEST_FRAME failed") @remote_compatible @@ -2348,7 +2348,7 @@ def test_ap_ft_ric(dev, apdev): dev[0].dump_monitor() def ie_hex(ies, id): - return binascii.hexlify(struct.pack('BB', id, len(ies[id])) + ies[id]) + return binascii.hexlify(struct.pack('BB', id, len(ies[id])) + ies[id]).decode() def test_ap_ft_reassoc_proto(dev, apdev): """WPA2-PSK-FT AP Reassociation Request frame parsing""" @@ -2375,7 +2375,7 @@ def test_ap_ft_reassoc_proto(dev, apdev): while True: req = hapd2ap.mgmt_rx() - hapd2ap.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame'])) + hapd2ap.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame']).decode()) if req['subtype'] == 11: break @@ -2383,10 +2383,10 @@ def test_ap_ft_reassoc_proto(dev, apdev): req = hapd2ap.mgmt_rx() if req['subtype'] == 2: break - hapd2ap.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame'])) + hapd2ap.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame']).decode()) # IEEE 802.11 header + fixed fields before IEs - hdr = binascii.hexlify(req['frame'][0:34]) + hdr = binascii.hexlify(req['frame'][0:34]).decode() ies = parse_ie(binascii.hexlify(req['frame'][34:])) # First elements: SSID, Supported Rates, Extended Supported Rates ies1 = ie_hex(ies, 0) + ie_hex(ies, 1) + ie_hex(ies, 50) @@ -2417,9 +2417,9 @@ def test_ap_ft_reassoc_proto(dev, apdev): # FT: R0KH-ID in FTIE did not match with the current R0KH-ID tests += [ rsne + mde + "3755" + fte[4:168] + "0301ff" ] # FT: No R1KH-ID subelem in FTIE - tests += [ rsne + mde + "375e" + fte[4:168] + "030a" + "nas1.w1.fi".encode("hex") ] + tests += [ rsne + mde + "375e" + fte[4:168] + "030a" + binascii.hexlify(b"nas1.w1.fi").decode() ] # FT: Unknown R1KH-ID used in ReassocReq - tests += [ rsne + mde + "3766" + fte[4:168] + "030a" + "nas1.w1.fi".encode("hex") + "0106000000000000" ] + tests += [ rsne + mde + "3766" + fte[4:168] + "030a" + binascii.hexlify(b"nas1.w1.fi").decode() + "0106000000000000" ] # FT: PMKID in Reassoc Req did not match with the PMKR1Name derived from auth request tests += [ rsne[:-32] + 16*"00" + mde + fte ] # Invalid MIC in FTIE @@ -2487,7 +2487,7 @@ def test_ap_ft_reassoc_replay(dev, apdev, params): req = hapd2ap.mgmt_rx() count += 1 hapd2ap.dump_monitor() - hapd2ap.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame'])) + hapd2ap.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame']).decode()) if req['subtype'] == 2: reassocreq = req ev = hapd2ap.wait_event(["MGMT-TX-STATUS"], timeout=5) @@ -2509,7 +2509,7 @@ def test_ap_ft_reassoc_replay(dev, apdev, params): logger.info("Replay the last Reassociation Request frame") hapd2ap.dump_monitor() hapd2ap.set("ext_mgmt_frame_handling", "1") - hapd2ap.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame'])) + hapd2ap.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + binascii.hexlify(req['frame']).decode()) ev = hapd2ap.wait_event(["MGMT-TX-STATUS"], timeout=5) if ev is None: raise Exception("No TX status seen") diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index 94673dd8f..780f18bc7 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -2350,7 +2350,12 @@ def read_process_memory(pid, key=None): mem.seek(start) data = mem.read(end - start) buf += data - if key and key in binascii.hexlify(data).decode(): + if key == None: + continue + converted_key = key + if not type(key) == bytes: + converted_key = binascii.unhexlify(key) + if converted_key in data: logger.info("Key found in " + l) logger.info("Total process memory read: %d bytes" % len(buf)) return buf -- 2.17.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap