tests: Use floor division (//) to avoid issues with python3

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-02-03 15:06:05 +02:00
parent 4d364d9ee0
commit 236bbda8e4
3 changed files with 6 additions and 6 deletions

View file

@ -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)]

View file

@ -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)

View file

@ -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")