From 236bbda8e4e1cf593951f9c499297bdfedefbf9d Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 3 Feb 2019 15:06:05 +0200 Subject: [PATCH] tests: Use floor division (//) to avoid issues with python3 Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_psk.py | 2 +- tests/hwsim/test_ap_wps.py | 8 ++++---- tests/hwsim/test_p2p_grpform.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index c10d835bd..9af31e24a 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -1617,7 +1617,7 @@ def build_eapol_key_3_4(anonce, kck, key_data, replay_counter=2, return msg def aes_wrap(kek, plain): - n = len(plain) / 8 + n = len(plain) // 8 a = 0xa6a6a6a6a6a6a6a6 enc = AES.new(kek).encrypt r = [plain[i * 8:(i + 1) * 8] for i in range(0, n)] diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index 3444954a0..9787dedf7 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -6280,7 +6280,7 @@ def wsc_kdf(key, label, bits): m = hmac.new(key, data, hashlib.sha256) result += m.digest() i += 1 - return result[0:bits / 8] + return result[0:bits // 8] def wsc_keys(kdk): keys = wsc_kdf(kdk, "Wi-Fi Easy and Secure Key Derivation", 640) @@ -6294,8 +6294,8 @@ def wsc_dev_pw_half_psk(authkey, dev_pw): return m.digest()[0:16] def wsc_dev_pw_psk(authkey, dev_pw): - dev_pw_1 = dev_pw[0:len(dev_pw) / 2] - dev_pw_2 = dev_pw[len(dev_pw) / 2:] + dev_pw_1 = dev_pw[0:len(dev_pw) // 2] + dev_pw_2 = dev_pw[len(dev_pw) // 2:] psk1 = wsc_dev_pw_half_psk(authkey, dev_pw_1) psk2 = wsc_dev_pw_half_psk(authkey, dev_pw_2) return psk1,psk2 @@ -6365,7 +6365,7 @@ def wsc_dh_kdf(peer_pk, own_private, mac_addr, e_nonce, r_nonce): peer_public = int(binascii.hexlify(peer_pk), 16) if peer_public < 2 or peer_public >= group_5_prime: raise Exception("Invalid peer public key") - if pow(peer_public, (group_5_prime - 1) / 2, group_5_prime) != 1: + if pow(peer_public, (group_5_prime - 1) // 2, group_5_prime) != 1: raise Exception("Unexpected Legendre symbol for peer public key") shared_secret = pow(peer_public, own_private, group_5_prime) diff --git a/tests/hwsim/test_p2p_grpform.py b/tests/hwsim/test_p2p_grpform.py index 8207cf12a..df13b19c3 100644 --- a/tests/hwsim/test_p2p_grpform.py +++ b/tests/hwsim/test_p2p_grpform.py @@ -1097,7 +1097,7 @@ def test_grpform_go_neg_dup_on_restart(dev): attrs = p2p_attr_capability(dev_capab=0x25, group_capab=0x08) attrs += p2p_attr_go_intent(go_intent=7, tie_breaker=1) attrs += p2p_attr_config_timeout() - attrs += p2p_attr_listen_channel(chan=(int(peer['listen_freq']) - 2407) / 5) + attrs += p2p_attr_listen_channel(chan=(int(peer['listen_freq']) - 2407) // 5) attrs += p2p_attr_intended_interface_addr(lower.p2p_dev_addr()) attrs += p2p_attr_channel_list() attrs += p2p_attr_device_info(addr_low, config_methods=0x80, name="Device A")