diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py index 2e6b9336c..338c1dd90 100644 --- a/tests/hwsim/test_dbus.py +++ b/tests/hwsim/test_dbus.py @@ -776,7 +776,7 @@ def _test_dbus_wps_pin(dev, apdev): def start_pin(self, *args): logger.debug("start_pin") - bssid_ay = dbus.ByteArray(bssid.replace(':','').decode('hex')) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) wps.Start({'Role': 'enrollee', 'Type': 'pin', 'Pin': '12345670', 'Bssid': bssid_ay}) return False @@ -836,7 +836,7 @@ def _test_dbus_wps_pin2(dev, apdev): def start_pin(self, *args): logger.debug("start_pin") - bssid_ay = dbus.ByteArray(bssid.replace(':','').decode('hex')) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) res = wps.Start({'Role': 'enrollee', 'Type': 'pin', 'Bssid': bssid_ay}) pin = res['Pin'] @@ -902,7 +902,7 @@ def _test_dbus_wps_pin_m2d(dev, apdev): def start_pin(self, *args): logger.debug("start_pin") - bssid_ay = dbus.ByteArray(bssid.replace(':','').decode('hex')) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) wps.Start({'Role': 'enrollee', 'Type': 'pin', 'Pin': '12345670', 'Bssid': bssid_ay}) return False @@ -957,7 +957,7 @@ def _test_dbus_wps_reg(dev, apdev): def start_reg(self, *args): logger.debug("start_reg") - bssid_ay = dbus.ByteArray(bssid.replace(':','').decode('hex')) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) wps.Start({'Role': 'registrar', 'Type': 'pin', 'Pin': '12345670', 'Bssid': bssid_ay}) return False @@ -981,7 +981,7 @@ def test_dbus_wps_cancel(dev, apdev): wps.Cancel() dev[0].scan_for_bss(bssid, freq="2412") - bssid_ay = dbus.ByteArray(bssid.replace(':','').decode('hex')) + bssid_ay = dbus.ByteArray(binascii.unhexlify(bssid.replace(':','').encode())) wps.Start({'Role': 'enrollee', 'Type': 'pin', 'Pin': '12345670', 'Bssid': bssid_ay}) wps.Cancel() diff --git a/tests/hwsim/test_macsec.py b/tests/hwsim/test_macsec.py index cc9bd3973..e760e76be 100644 --- a/tests/hwsim/test_macsec.py +++ b/tests/hwsim/test_macsec.py @@ -6,6 +6,7 @@ import logging logger = logging.getLogger() +import binascii import os import signal import subprocess @@ -175,9 +176,9 @@ def lower_addr(addr1, addr2): a1 = addr1.split(':') a2 = addr2.split(':') for i in range(6): - if a1[i].decode("hex") < a2[i].decode("hex"): + if binascii.unhexlify(a1[i]) < binascii.unhexlify(a2[i]): return True - if a1[i].decode("hex") > a2[i].decode("hex"): + if binascii.unhexlify(a1[i]) > binascii.unhexlify(a2[i]): return False return False diff --git a/tests/hwsim/test_mbo.py b/tests/hwsim/test_mbo.py index a36aee2ba..2a177c609 100644 --- a/tests/hwsim/test_mbo.py +++ b/tests/hwsim/test_mbo.py @@ -449,7 +449,7 @@ def test_mbo_sta_supp_op_classes(dev, apdev): logger.debug("STA: " + str(sta)) if 'supp_op_classes' not in sta: raise Exception("No supp_op_classes") - supp = bytearray(sta['supp_op_classes'].decode("hex")) + supp = bytearray(binascii.unhexlify(sta['supp_op_classes'])) if supp[0] != 81: raise Exception("Unexpected current operating class %d" % supp[0]) if 115 not in supp: diff --git a/tests/hwsim/test_sigma_dut.py b/tests/hwsim/test_sigma_dut.py index 8bc45d967..9375421bf 100644 --- a/tests/hwsim/test_sigma_dut.py +++ b/tests/hwsim/test_sigma_dut.py @@ -30,6 +30,9 @@ def check_sigma_dut(): def to_hex(s): return binascii.hexlify(s.encode()).decode() +def from_hex(s): + return binascii.unhexlify(s).decode() + def sigma_dut_cmd(cmd, port=9000, timeout=2): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) @@ -968,7 +971,7 @@ def run_sigma_dut_dpp_qr_resp(dev, apdev, conf_idx, chan_list=None, if "status,COMPLETE" not in res: raise Exception("dev_exec_action did not succeed: " + res) hex = res.split(',')[3] - uri = hex.decode('hex') + uri = from_hex(hex) logger.info("URI from sigma_dut: " + uri) res = dev[1].request("DPP_QR_CODE " + uri) @@ -1105,7 +1108,7 @@ def run_sigma_dut_dpp_qr_mutual_init_enrollee_check(dev, apdev, extra=''): if "status,COMPLETE" not in res: raise Exception("dev_exec_action did not succeed: " + res) hex = res.split(',')[3] - uri = hex.decode('hex') + uri = from_hex(hex) logger.info("URI from sigma_dut: " + uri) res = dev[1].request("DPP_QR_CODE " + uri) @@ -1189,7 +1192,7 @@ def run_sigma_dut_dpp_qr_mutual_resp_enrollee(dev, apdev, extra=None): if "status,COMPLETE" not in res: raise Exception("dev_exec_action did not succeed: " + res) hex = res.split(',')[3] - uri = hex.decode('hex') + uri = from_hex(hex) logger.info("URI from sigma_dut: " + uri) res = dev[1].request("DPP_QR_CODE " + uri) @@ -1288,7 +1291,7 @@ def run_sigma_dut_dpp_qr_mutual_init_enrollee(dev, apdev, resp_pending): if "status,COMPLETE" not in res: raise Exception("dev_exec_action did not succeed: " + res) hex = res.split(',')[3] - uri = hex.decode('hex') + uri = from_hex(hex) logger.info("URI from sigma_dut: " + uri) if not resp_pending: @@ -1485,7 +1488,7 @@ def test_sigma_dut_dpp_incompatible_roles_init(dev, apdev): if "status,COMPLETE" not in res: raise Exception("dev_exec_action did not succeed: " + res) hex = res.split(',')[3] - uri = hex.decode('hex') + uri = from_hex(hex) logger.info("URI from sigma_dut: " + uri) res = dev[1].request("DPP_QR_CODE " + uri) @@ -1539,7 +1542,7 @@ def test_sigma_dut_dpp_incompatible_roles_resp(dev, apdev): if "status,COMPLETE" not in res: raise Exception("dev_exec_action did not succeed: " + res) hex = res.split(',')[3] - uri = hex.decode('hex') + uri = from_hex(hex) logger.info("URI from sigma_dut: " + uri) res = dev[1].request("DPP_QR_CODE " + uri) @@ -1629,7 +1632,7 @@ def run_sigma_dut_ap_dpp_qr(dev, apdev, params, ap_conf, sta_conf, extra=""): if "status,COMPLETE" not in res: raise Exception("dev_exec_action did not succeed: " + res) hex = res.split(',')[3] - uri = hex.decode('hex') + uri = from_hex(hex) logger.info("URI from sigma_dut: " + uri) cmd = "DPP_CONFIGURATOR_ADD" @@ -1850,7 +1853,7 @@ def run_sigma_dut_dpp_proto_responder(dev, step, frame, attr, result, fail): if "status,COMPLETE" not in res: raise Exception("dev_exec_action did not succeed: " + res) hex = res.split(',')[3] - uri = hex.decode('hex') + uri = from_hex(hex) logger.info("URI from sigma_dut: " + uri) res = dev[1].request("DPP_QR_CODE " + uri) @@ -1992,7 +1995,7 @@ def run_sigma_dut_dpp_proto_stop_at_responder(dev, frame, result, fail): if "status,COMPLETE" not in res: raise Exception("dev_exec_action did not succeed: " + res) hex = res.split(',')[3] - uri = hex.decode('hex') + uri = from_hex(hex) logger.info("URI from sigma_dut: " + uri) res = dev[1].request("DPP_QR_CODE " + uri)