From: Masashi Honma Date: Sat, 2 Feb 2019 11:01:36 +0000 (+0200) Subject: tests: Convert binascii.hexlify() output to a string object for python3 X-Git-Tag: hostap_2_8~473 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ab74770e730d7e223007d35bda052b8228afa83;p=thirdparty%2Fhostap.git tests: Convert binascii.hexlify() output to a string object for python3 This is needed in cases the hexlify() output is used to concatenate with a string or used in string comparisons. Signed-off-by: Masashi Honma Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 69d3e3135..3bbc1e5c2 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -329,7 +329,8 @@ class Hostapd: def mgmt_tx(self, msg): t = (msg['fc'], 0) + mac2tuple(msg['da']) + mac2tuple(msg['sa']) + mac2tuple(msg['bssid']) + (0,) hdr = struct.pack(' +# Copyright (c) 2013-2019, Jouni Malinen # # This software may be distributed under the terms of the BSD license. # See README for more details. @@ -247,7 +247,7 @@ def send_eapol_key(dev, bssid, signkey, frame_start, frame_end): hmac_obj = hmac.new(binascii.unhexlify(signkey)) hmac_obj.update(binascii.unhexlify(frame)) sign = hmac_obj.digest() - frame = frame_start + binascii.hexlify(sign) + frame_end + frame = frame_start + binascii.hexlify(sign).decode() + frame_end dev.request("EAPOL_RX " + bssid + " " + frame) def test_ieee8021x_eapol_key(dev, apdev): diff --git a/tests/hwsim/test_kernel.py b/tests/hwsim/test_kernel.py index f2b072300..de81ac06b 100644 --- a/tests/hwsim/test_kernel.py +++ b/tests/hwsim/test_kernel.py @@ -39,7 +39,7 @@ def _test_kernel_bss_leak(dev, apdev, deauth): break else: hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % ( - binascii.hexlify(pkt['frame']), )) + binascii.hexlify(pkt['frame']).decode(), )) hapd.set("ext_mgmt_frame_handling", "0") hapd.request("STOP_AP") diff --git a/tests/hwsim/test_p2p_grpform.py b/tests/hwsim/test_p2p_grpform.py index b967085f9..8207cf12a 100644 --- a/tests/hwsim/test_p2p_grpform.py +++ b/tests/hwsim/test_p2p_grpform.py @@ -1104,7 +1104,7 @@ def test_grpform_go_neg_dup_on_restart(dev): attrs += p2p_attr_operating_channel() wsc_attrs = struct.pack(">HHH", 0x1012, 2, 4) msg['payload'] += ie_p2p(attrs) + ie_wsc(wsc_attrs) - mgmt_tx(lower, "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr_high, addr_high, peer['listen_freq'], binascii.hexlify(msg['payload']))) + mgmt_tx(lower, "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr_high, addr_high, peer['listen_freq'], binascii.hexlify(msg['payload']).decode())) # Wait for the GO Negotiation Response frame which would have been sent in # this case previously, but not anymore after the check for diff --git a/tests/hwsim/test_p2p_messages.py b/tests/hwsim/test_p2p_messages.py index 7befbdce1..d4c39b82d 100644 --- a/tests/hwsim/test_p2p_messages.py +++ b/tests/hwsim/test_p2p_messages.py @@ -800,7 +800,7 @@ def test_p2p_msg_invitation_req_to_go(dev, apdev): attrs += p2p_attr_device_info(addr1, config_methods=0x0108) msg['payload'] += ie_p2p(attrs) - mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, peer['listen_freq'], binascii.hexlify(msg['payload']))) + mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, peer['listen_freq'], binascii.hexlify(msg['payload']).decode())) rx_msg = dev[1].mgmt_rx() if rx_msg is None: @@ -826,7 +826,7 @@ def test_p2p_msg_invitation_req_to_go(dev, apdev): attrs += p2p_attr_device_info(addr1, config_methods=0x0108) msg['payload'] += ie_p2p(attrs) - mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, peer['listen_freq'], binascii.hexlify(msg['payload']))) + mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, peer['listen_freq'], binascii.hexlify(msg['payload']).decode())) rx_msg = dev[1].mgmt_rx() if rx_msg is None: @@ -907,7 +907,8 @@ def test_p2p_msg_invitation_resp(dev, apdev): msg = p2p_hdr(dst, src, type=P2P_INVITATION_RESP, dialog_token=2) attrs = p2p_attr_status() msg['payload'] += ie_p2p(attrs) - mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, peer['listen_freq'], binascii.hexlify(msg['payload']))) + mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format( + addr0, addr0, peer['listen_freq'], binascii.hexlify(msg['payload']).decode())) time.sleep(0.25) if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 1"): @@ -927,7 +928,8 @@ def test_p2p_msg_invitation_resp(dev, apdev): msg = p2p_hdr(dst, src, type=P2P_INVITATION_RESP, dialog_token=p2p['dialog_token']) attrs = struct.pack("